:root {
  --surface: #ffffff;
  --surface-subtle: #f3f6f9;
  --primary: #2d5da1;
  --primary-subtle: #e5ecf6;
  --primary-hover: #234a82;
  --text: #0f0f0f;
  --text-subtle: #606060;
  --border: #dadce0;
  --border-strong: #c0c0c0;
  --danger: #c5221f;
  --danger-subtle: #fce8e6;
  --success: #188038;
  --success-subtle: #e6f4ea;
  --warning: #c25e00;
  --warning-subtle: #fff3e0;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --duration: 140ms;
}

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

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

[hidden] {
  display: none !important;
}

body {
  min-width: 360px;
  min-height: 100vh;
  font-size: 14px;
  color: var(--text);
  font-family: "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", system-ui, sans-serif;
  background: #f3f6f9;
}

body.wordmark-body {
  min-width: 0;
  display: grid;
  place-items: center;
}

body.mobile-body {
  min-width: 0;
  background: #f8fafd;
}

a {
  color: inherit;
  text-decoration: none;
}

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

a,
button,
input,
textarea,
select,
.button,
.card,
.panel,
.table-card,
.metric {
  transition:
    background-color var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    color var(--duration) var(--ease),
    transform var(--duration) var(--ease),
    opacity var(--duration) var(--ease);
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 20px 72px;
}

.login-main {
  max-width: 560px;
}

.login-main .hero,
.login-main .layout {
  max-width: 100%;
}

.wordmark-main {
  min-height: 100vh;
  width: 100%;
  max-width: none;
  display: grid;
  place-items: center;
  padding: 32px;
}

.wordmark-title {
  margin: 0;
  font-size: clamp(32px, 7vw, 72px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--primary);
}

body.admin-body {
  min-width: 0;
  overflow: hidden;
}

.admin-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 60px;
  padding: 0 28px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.admin-topbar-title-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--primary);
  flex: 0 0 auto;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  clip-path: circle(50% at 50% 50%);
  appearance: none;
  -webkit-appearance: none;
  background-clip: padding-box;
  box-shadow: none;
  cursor: pointer;
}

.admin-sidebar-toggle svg {
  display: block;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}

.admin-sidebar-toggle:hover {
  background: var(--primary-subtle);
  border-color: var(--primary);
}

.admin-sidebar-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.admin-topbar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.admin-topbar-subtle {
  margin-top: 0;
  color: var(--text-subtle);
  font-size: 13px;
}

/* ---- User avatar menu ---- */
.user-menu {
  position: relative;
}

.user-avatar-stack {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.12s;
}

.user-avatar:hover {
  opacity: 0.85;
}

.user-avatar--large {
  width: 48px;
  height: 48px;
  font-size: 18px;
  cursor: default;
  flex-shrink: 0;
}

.user-avatar--large:hover {
  transform: none;
  box-shadow: none;
}

.user-avatar-impersonation-badge {
  position: absolute;
  right: -4px;
  bottom: -3px;
  z-index: 2;
  pointer-events: none;
  padding: 2px 4px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-subtle);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.06em;
}

.user-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.user-popover-section {
  padding: 16px;
}

.user-popover-section + .user-popover-section {
  border-top: 1px solid var(--border);
}

.user-popover-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-popover-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
}

.user-popover-name {
  font-size: 14px;
  font-weight: 700;
  margin-top: 2px;
}

.user-popover-sub {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 1px;
}

.user-popover-actions {
  padding: 12px 16px;
}

.mobile-app {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  margin: 0 auto;
  background: #f8fafd;
}

.mobile-top-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  min-height: calc(54px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.mobile-top-nav-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-top-nav-title {
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.mobile-top-nav-side {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.mobile-top-nav-side-right {
  justify-content: flex-end;
}

.mobile-user-menu {
  display: inline-flex;
}

.mobile-user-avatar {
  width: 36px;
  height: 36px;
  font-size: 13px;
}

.mobile-user-popover {
  min-width: 220px;
  max-width: min(280px, calc(100vw - 24px));
}

.mobile-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  color: var(--primary);
  font-size: 28px;
  line-height: 1;
}

.mobile-icon-button-muted {
  opacity: 0;
}

.mobile-content {
  display: grid;
  gap: 14px;
  padding: 12px 12px calc(20px + env(safe-area-inset-bottom));
}

.mobile-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.mobile-section-title {
  display: grid;
  gap: 6px;
}

.mobile-section-title h2 {
  margin: 0;
  font-size: 17px;
}

.mobile-section-title p {
  margin: 0;
  font-size: 12px;
  color: var(--text-subtle);
  line-height: 1.5;
}

.mobile-bams-hero {
  gap: 12px;
}

.mobile-bams-detail-hero {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  box-shadow: 0 8px 24px rgba(45, 93, 161, 0.22);
}

.mobile-bams-detail-hero-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.mobile-bams-detail-hero-heading {
  min-width: 0;
}

.mobile-bams-detail-hero-label {
  margin: 0;
  font-size: 11px;
  opacity: 0.85;
}

.mobile-bams-detail-hero-no {
  margin: 2px 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.mobile-bams-detail-hero-who {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  opacity: 0.92;
}

.mobile-bams-detail-hero .pill {
  background: #fff;
  color: var(--primary);
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.mobile-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mobile-meta-pills li {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.mobile-meta-pills li time {
  color: inherit;
}

.mobile-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 4px 2px 8px;
}

.mobile-section-head h2 {
  margin: 0;
  font-size: 15px;
}

.mobile-section-count {
  font-size: 12px;
  color: var(--text-subtle);
}

.mobile-doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.mobile-doc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.mobile-doc-row:active {
  transform: scale(0.995);
  box-shadow: none;
}

.mobile-doc-row-body {
  flex: 1;
  min-width: 0;
}

.mobile-doc-row-meta {
  margin: 0;
  font-size: 11px;
  color: var(--text-subtle);
}

.mobile-doc-row-title {
  margin: 2px 0 2px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.mobile-doc-row-sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-subtle);
}

.mobile-doc-row-arrow {
  color: var(--primary);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

.mobile-bams-confirm-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.mobile-bams-confirm-head h2 {
  margin: 0;
  font-size: 15px;
}

.mobile-sticky-action {
  position: sticky;
  bottom: env(safe-area-inset-bottom);
  margin: 4px -12px calc(-20px - env(safe-area-inset-bottom));
  padding: 12px 12px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, #fff 55%, rgba(255, 255, 255, 0));
  z-index: 5;
}

.mobile-sticky-action form {
  margin: 0;
}

.mobile-sticky-action button {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  border-radius: 14px;
}

.mobile-bams-correction-panel {
  padding: 0;
  overflow: hidden;
}

.mobile-bams-correction-summary {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 47px;
  padding: 14px 44px;
  color: var(--primary);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.mobile-bams-correction-summary::-webkit-details-marker {
  display: none;
}

.mobile-bams-correction-summary::after {
  content: "";
  position: absolute;
  right: 18px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-subtle);
  border-bottom: 2px solid var(--text-subtle);
  transform: translateY(-65%) rotate(45deg);
}

.mobile-bams-correction-panel[open] .mobile-bams-correction-summary {
  border-bottom: 1px solid var(--border);
}

.mobile-bams-correction-panel[open] .mobile-bams-correction-summary::after {
  transform: translateY(-25%) rotate(-135deg);
}

.mobile-bams-correction-panel form {
  padding: 14px;
}

.mobile-bams-correction-form {
  display: grid;
  gap: 13px;
}

.mobile-bams-correction-methods {
  display: grid;
  gap: 9px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.mobile-bams-correction-methods legend {
  margin: 0 0 4px;
  padding: 0;
  font-size: 13px;
  font-weight: 700;
}

.mobile-bams-correction-methods .subtle {
  margin: 0 0 2px;
  font-size: 12px;
}

.mobile-bams-correction-method {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.mobile-bams-correction-method:has(input:checked) {
  border-color: var(--primary);
  background: #eef5ff;
}

.mobile-bams-correction-method input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

.mobile-bams-correction-method-body,
.mobile-bams-correction-method-title,
.mobile-bams-correction-method-description {
  display: block;
  min-width: 0;
}

.mobile-bams-correction-method-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.mobile-bams-correction-method-description {
  margin-top: 3px;
  color: var(--text-subtle);
  font-size: 12px;
  line-height: 1.55;
}

.mobile-bams-correction-method-tag,
.mobile-bams-correction-comment-tag {
  flex: 0 0 auto;
  min-width: 40px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #eef2f7;
  color: var(--text-subtle);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}

.mobile-bams-correction-method-tag.is-required,
.mobile-bams-correction-comment-tag.is-required {
  background: #fff0f0;
  color: var(--danger);
}

.mobile-bams-correction-comment {
  display: grid;
  gap: 7px;
}

.mobile-bams-correction-comment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.mobile-bams-correction-comment textarea {
  min-height: 88px;
}

.mobile-paper-card-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.mobile-paper-card-code {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.mobile-paper-card-sub {
  margin: 2px 0 0;
  font-size: 11px;
  line-height: 1.5;
}

.mobile-paper-card-body {
  padding: 12px 14px;
}

.mobile-doc-stack {
  display: grid;
  gap: 12px;
}

.mobile-doc-h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
}

.mobile-form-pager {
  position: sticky;
  bottom: env(safe-area-inset-bottom);
  margin: 4px -12px calc(-20px - env(safe-area-inset-bottom));
  padding: 12px 12px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, #fff 55%, rgba(255, 255, 255, 0));
  z-index: 5;
  display: flex;
  gap: 8px;
}

.mobile-form-pager > * {
  flex: 1 1 0;
}

.mobile-form-pager .button {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  border-radius: 14px;
  text-align: center;
}

.mobile-view-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.mobile-view-mode-switch a {
  display: block;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--text-subtle);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.mobile-view-mode-switch a.is-active {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.mobile-view-mode-switch + .mobile-doc-list {
  margin-top: 8px;
}

.mobile-form-layout,
.mobile-form-main {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.mobile-form-toolbar {
  display: grid;
  gap: 8px;
}

.mobile-form-document-nav {
  display: none;
}

.mobile-impersonation-banner {
  border: 1px solid #f7c948;
  border-radius: 8px;
  background: #fff8db;
  color: #5c4200;
  padding: 10px 12px;
  display: grid;
  gap: 10px;
}

.mobile-impersonation-banner p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
}

.mobile-impersonation-banner form {
  display: flex;
  justify-content: center;
  margin: 0;
}

.mobile-impersonation-banner button {
  width: min(240px, 100%);
}

.mobile-form-template-stack {
  display: grid;
  gap: 14px;
}

.mobile-form-template-section {
  display: grid;
  gap: 8px;
}

.mobile-form-template-title {
  padding: 0 2px;
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 700;
}

.mobile-form-template-scroll {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  box-shadow: var(--shadow-xs);
  -webkit-overflow-scrolling: touch;
}

.mobile-form-template-page {
  position: relative;
  flex: 0 0 auto;
  background: #fff;
}

.mobile-form-template-page img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  pointer-events: none;
}

@media (max-width: 899px) {
  .mobile-form-main:has(.mobile-form-template-stack) {
    gap: 10px;
  }

  .mobile-form-main:has(.mobile-form-template-stack) .mobile-form-toolbar {
    padding-inline: 0;
  }

  .mobile-form-template-stack {
    gap: 10px;
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
  }

  .mobile-form-template-section {
    width: 100vw;
    max-width: 100vw;
    margin-inline: calc(50% - 50vw);
    gap: 4px;
  }

  .mobile-form-template-title {
    padding-inline: 12px;
  }

  .mobile-form-template-scroll {
    width: 100%;
    border-right: none;
    border-left: none;
    border-radius: 0;
    box-shadow: none;
  }
}

.mobile-form-template-field {
  position: absolute;
  z-index: 1;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  color: #d00000;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-form-template-field--wrap {
  white-space: pre-wrap;
  overflow: hidden;
  text-overflow: clip;
}

.mobile-form-template-field--check {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  color: #d00000;
  font-weight: 900;
  line-height: 1;
}

.mobile-form-template-field--char {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.mobile-form-template-field--whiteout {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 1px 4px;
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.94));
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.9),
    0 0 4px rgba(255, 255, 255, 0.6);
  box-sizing: border-box;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  overflow: visible;
  text-overflow: clip;
}

.mobile-form-template-field--whiteout .mobile-form-template-char-cell {
  display: inline;
}

.mobile-form-template-field--char-field.mobile-form-template-field--whiteout {
  letter-spacing: var(--template-char-gap, 0px);
}

.mobile-form-template-field--char-cells {
  display: grid;
  grid-template-columns: repeat(var(--template-char-count, 1), minmax(0, 1fr));
  column-gap: var(--template-char-gap, 0px);
  align-items: stretch;
  justify-items: stretch;
  line-height: 1;
}

.mobile-form-template-char-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.mobile-template-layout-edit-notice {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 13px;
}

.mobile-form-template-page--layout-edit {
  isolation: isolate;
  cursor: crosshair;
}

.mobile-form-template-page--layout-edit::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image:
    linear-gradient(to right, rgba(37, 99, 235, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(37, 99, 235, 0.08) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
}

.mobile-form-template-field--editable {
  cursor: crosshair;
}

.template-layout-edit-marquee {
  position: absolute;
  z-index: 5;
  box-sizing: border-box;
  border: 1px solid #2563eb;
  background: rgba(37, 99, 235, 0.12);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.18);
  pointer-events: none;
}

.show-template-layout-boxes .mobile-form-template-field--editable {
  outline: 1px dashed rgba(37, 99, 235, 0.7);
  outline-offset: 0;
}

.mobile-form-template-field--editable.is-template-layout-selected {
  outline: 2px solid #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.mobile-form-template-field--editable.is-template-layout-primary-selected {
  outline-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}

.show-template-layout-ids .mobile-form-template-field--editable::after {
  content: attr(data-template-field-id);
  position: absolute;
  left: 0;
  bottom: 100%;
  z-index: 3;
  max-width: 280px;
  padding: 2px 4px;
  border-radius: 4px;
  background: #1d4ed8;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
}

.show-template-layout-grid .mobile-form-template-page--layout-edit::before {
  background-image:
    linear-gradient(to right, rgba(37, 99, 235, 0.18) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(37, 99, 235, 0.18) 1px, transparent 1px),
    linear-gradient(to right, rgba(37, 99, 235, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(37, 99, 235, 0.08) 1px, transparent 1px);
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
}

.template-layout-edit-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  width: min(420px, calc(100vw - 32px));
  max-height: min(78vh, 720px);
  overflow: auto;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-md);
  color: var(--text);
}

.template-layout-edit-panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  cursor: move;
  user-select: none;
}

.template-layout-edit-panel__head span {
  color: var(--text-subtle);
  font-size: 12px;
}

.template-layout-edit-panel--dragging {
  opacity: 0.92;
}

body.template-layout-edit-panel-dragging {
  cursor: move;
  user-select: none;
}

.template-layout-edit-help {
  padding: 8px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 12px;
  line-height: 1.5;
}

.template-layout-edit-selection-count {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--primary-subtle);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.template-layout-edit-draft-status {
  width: fit-content;
  padding: 4px 8px;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 700;
}

.template-layout-edit-toggles,
.template-layout-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-layout-edit-toggles label {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  font-size: 12px;
}

.template-layout-edit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.template-layout-edit-field {
  display: grid;
  gap: 3px;
  min-width: 0;
  color: var(--text-subtle);
  font-size: 11px;
  font-weight: 700;
}

.template-layout-edit-field input,
.template-layout-edit-field select {
  width: 100%;
  min-width: 0;
  height: 30px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.template-layout-edit-checkbox {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 30px;
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.template-layout-edit-checkbox input {
  margin: 0;
}

.template-layout-edit-move {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.template-layout-edit-panel button {
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.admin-json-preview {
  max-width: min(960px, 72vw);
  max-height: 360px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.mobile-form-template-overflow {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.mobile-form-template-overflow h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

.mobile-form-template-overflow ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 18px;
  color: var(--text-subtle);
  font-size: 12px;
  line-height: 1.5;
}

.mobile-form-template-overflow--records {
  display: grid;
  gap: 8px;
}

.mobile-form-template-overflow--records h3 {
  margin-bottom: 0;
}

.mobile-form-template-overflow--records .mobile-record-title,
.mobile-form-template-overflow--records .mobile-record-meta dd {
  color: #d00000;
  font-weight: 700;
}

.mobile-record-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mobile-record {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.mobile-record-title {
  margin: 0 0 2px;
  padding-bottom: 6px;
  border-bottom: 1px solid #eeeeee;
  font-size: 13px;
  font-weight: 700;
  word-break: break-word;
}

.mobile-record-meta {
  display: grid;
  gap: 0;
  margin: 0;
}

.mobile-record-meta > div {
  display: block;
  padding: 8px 0;
  border-bottom: 1px solid #eeeeee;
}

.mobile-record-meta > div:last-child {
  border-bottom: none;
}

.mobile-record-meta dt {
  display: block;
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-subtle);
}

.mobile-record-meta dd {
  display: block;
  margin: 0;
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

.mobile-responsive-record-table-wrap {
  display: none;
}

.mobile-responsive-record-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
}

.mobile-responsive-record-table th,
.mobile-responsive-record-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eeeeee;
  vertical-align: middle;
  text-align: left;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.mobile-responsive-record-table th {
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 700;
  background: #f8fafc;
}

.mobile-responsive-record-table td {
  color: #d00000;
  font-weight: 700;
}

.mobile-responsive-record-table td:nth-child(3) {
  text-align: right;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .mobile-responsive-records > .mobile-record-list {
    display: none;
  }

  .mobile-responsive-record-table-wrap {
    display: block;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
  }
}

.mobile-note {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-subtle);
  font-size: 12px;
  line-height: 1.7;
}

.mobile-insurance-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.mobile-insurance-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.32fr) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #eeeeee;
}

.mobile-insurance-row:last-child {
  border-bottom: none;
}

.mobile-insurance-label {
  color: var(--text-subtle);
  font-size: 13px;
}

.mobile-insurance-value {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.mobile-insurance-value--enrolled {
  color: var(--success);
}

.mobile-insurance-value--unenrolled {
  color: var(--text-subtle);
}

.mobile-insurance-value--unknown {
  color: var(--text);
  font-weight: 500;
}

.mobile-insurance-value-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  color: #ffffff;
}

.mobile-insurance-value--enrolled .mobile-insurance-value-icon {
  background: var(--success);
}

.mobile-insurance-value--unenrolled .mobile-insurance-value-icon {
  background: #c0c4c9;
}

/* モバイルのラベル/値テーブル（tbody のみ、行頭 <th>）は行を縦積みにして読みやすくする */
body.mobile-body .mobile-app .table:not(:has(thead)) tbody tr {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid #eeeeee;
}

body.mobile-body .mobile-app .table:not(:has(thead)) tbody tr:last-child {
  border-bottom: none;
}

body.mobile-body .mobile-app .table:not(:has(thead)) tbody th,
body.mobile-body .mobile-app .table:not(:has(thead)) tbody td {
  display: block;
  padding: 0;
  border: none;
  white-space: normal;
  word-break: break-word;
}

body.mobile-body .mobile-app .table:not(:has(thead)) tbody th {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-subtle);
}

body.mobile-body .mobile-app .table:not(:has(thead)) tbody td {
  font-size: 14px;
  color: var(--text);
}

/* thead 付きの横長テーブルはラッパに .table-scroll が使われる。モバイル向けに余白を詰める */
body.mobile-body .mobile-app .table-scroll > table th,
body.mobile-body .mobile-app .table-scroll > table td {
  padding: 8px 10px;
  font-size: 12px;
}

/* タップ領域とフッタボタンの横並び用 */
body.mobile-body .mobile-app .button,
body.mobile-body .mobile-app button:not(.user-avatar) {
  min-height: 44px;
}

.mobile-footer-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.mobile-footer-actions > * {
  flex: 1 1 0;
}

.mobile-footer-actions form {
  flex: 1 1 0;
}

.mobile-footer-actions form button {
  width: 100%;
}

@media (min-width: 900px) {
  body.mobile-body {
    background: #eef2f6;
  }

  .mobile-app {
    max-width: none;
    background: #f8fafd;
  }

  .mobile-top-nav {
    grid-template-columns: 64px 1fr 64px;
    min-height: 64px;
    padding: 0 20px;
  }

  .mobile-top-nav-title {
    font-size: 19px;
  }

  .mobile-content {
    gap: 18px;
    padding: 20px 32px 40px;
  }

  .mobile-panel,
  .mobile-bams-detail-hero,
  .mobile-paper-card,
  .mobile-record,
  .mobile-note,
  .mobile-form-template-scroll,
  .mobile-form-template-overflow,
  .mobile-doc-row {
    border-radius: 8px;
  }

  .mobile-bams-detail-hero {
    padding: 20px 22px;
  }

  .mobile-bams-detail-hero-no {
    font-size: 28px;
  }

  .mobile-meta-pills li {
    font-size: 12px;
  }

  .mobile-doc-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .mobile-doc-row {
    min-height: 92px;
    align-items: flex-start;
    padding: 14px 16px;
  }

  .mobile-doc-row:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
  }

  .mobile-doc-row-title {
    font-size: 16px;
  }

  .mobile-doc-row-sub {
    font-size: 13px;
  }

  .mobile-bams-confirm-panel {
    border-radius: 8px;
  }

  .mobile-sticky-action,
  .mobile-form-pager {
    position: static;
    margin: 0;
    padding: 0;
    background: none;
  }

  .mobile-sticky-action button,
  .mobile-bams-correction-summary,
  .mobile-form-pager .button {
    border-radius: 8px;
  }

  .mobile-form-layout {
    grid-template-columns: 260px minmax(0, 1fr);
    align-items: start;
    gap: 20px;
  }

  .mobile-form-document-nav {
    position: sticky;
    top: 84px;
    display: block;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow-xs);
  }

  .mobile-form-document-nav-label {
    margin: 0 0 10px;
    color: var(--text-subtle);
    font-size: 12px;
    font-weight: 700;
  }

  .mobile-form-document-nav ol {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .mobile-form-document-nav a {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 10px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
  }

  .mobile-form-document-nav a:hover {
    background: var(--surface-subtle);
  }

  .mobile-form-document-nav a[aria-current="page"] {
    background: var(--primary-subtle);
    color: var(--primary);
    font-weight: 700;
  }

  .mobile-form-document-nav-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: var(--surface-subtle);
    color: var(--text-subtle);
    font-size: 12px;
    font-weight: 700;
  }

  .mobile-form-document-nav a[aria-current="page"] .mobile-form-document-nav-index {
    background: var(--primary);
    color: #fff;
  }

  .mobile-form-document-nav-text {
    display: grid;
    gap: 2px;
    min-width: 0;
  }

  .mobile-form-document-nav-title,
  .mobile-form-document-nav-code {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-form-document-nav-title {
    font-size: 13px;
  }

  .mobile-form-document-nav-code {
    color: var(--text-subtle);
    font-size: 11px;
    font-weight: 500;
  }

  .mobile-form-toolbar {
    justify-self: end;
    width: min(320px, 100%);
  }

  .mobile-form-main {
    min-width: 0;
  }

  .mobile-paper-card-body {
    padding: 16px 18px;
  }

  .mobile-doc-stack {
    gap: 16px;
  }

  .mobile-record-list {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
  }

  .mobile-record-meta > div {
    display: grid;
    grid-template-columns: minmax(120px, 0.4fr) minmax(0, 1fr);
    gap: 12px;
    align-items: baseline;
  }

  .mobile-record-meta dt {
    margin: 0;
  }

  body.mobile-body .mobile-app .table:not(:has(thead)) tbody tr {
    grid-template-columns: minmax(180px, 0.32fr) minmax(0, 1fr);
    gap: 16px;
    align-items: baseline;
  }

  body.mobile-body .mobile-app .table:not(:has(thead)) tbody th {
    font-size: 12px;
  }

  body.mobile-body .mobile-app .table:not(:has(thead)) tbody td {
    font-size: 14px;
  }

  body.mobile-body .mobile-app .table-scroll > table th,
  body.mobile-body .mobile-app .table-scroll > table td {
    padding: 9px 11px;
    font-size: 13px;
  }

  .mobile-form-template-stack {
    gap: 18px;
  }

  .mobile-form-template-title {
    font-size: 13px;
  }

  .mobile-form-template-scroll {
    overflow-y: visible;
  }

  .mobile-form-pager {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 180px));
    justify-content: end;
  }
}

.admin-layout {
  --admin-sidebar-width: 220px;
  --admin-sidebar-resizer-track: 6px;
  display: grid;
  grid-template-columns: var(--admin-sidebar-width) var(--admin-sidebar-resizer-track) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.admin-layout.admin-sidebar-collapsed {
  --admin-sidebar-width: 64px;
  --admin-sidebar-resizer-track: 0px;
}

.admin-sidebar {
  background: var(--surface);
  border-right: none;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.admin-sidebar-resizer {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 0;
  border: 0;
  width: 100%;
  min-height: 0;
  align-self: stretch;
  cursor: col-resize;
  touch-action: none;
  background: transparent;
  flex-shrink: 0;
}

.admin-sidebar-resizer::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  transform: translateX(-50%);
  background: #e5e5e5;
  pointer-events: none;
}

.admin-sidebar-resizer:hover::after,
.admin-sidebar-resizer:focus-visible::after {
  width: 2px;
  background: #9ca3af;
}

body.admin-sidebar-resizing {
  cursor: col-resize;
  user-select: none;
}

.admin-sidebar-overlay {
  display: none;
}

.admin-layout.admin-sidebar-collapsed .admin-sidebar-resizer {
  display: none;
}

.admin-nav {
  padding: 12px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.admin-layout.admin-sidebar-collapsed .admin-nav {
  align-items: center;
  padding: 12px 8px 20px;
}

.admin-layout.admin-sidebar-collapsed .nav-section {
  width: 100%;
}

.admin-layout.admin-sidebar-collapsed .nav-section-label,
.admin-layout.admin-sidebar-collapsed .nav-divider,
.admin-layout.admin-sidebar-collapsed .nav-link-label,
.admin-layout.admin-sidebar-collapsed .nav-link-meta,
.admin-layout.admin-sidebar-collapsed .nav-link-badge,
.admin-layout.admin-sidebar-collapsed .nav-link-badge-stack {
  display: none;
}

.admin-layout.admin-sidebar-collapsed .nav-link {
  justify-content: center;
  height: 42px;
  padding: 0 8px;
}

.admin-layout.admin-sidebar-collapsed .nav-link-main {
  justify-content: center;
  gap: 0;
}

.nav-divider {
  height: 1px;
  background: #e5e5e5;
  margin: 12px 16px;
}

.nav-section {
  margin-top: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.nav-section-label {
  display: block;
  margin: 0;
  padding: 8px 12px 4px 16px;
  color: #606060;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.nav-section-label::before,
.nav-section-label::after {
  content: none;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  gap: 10px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  min-width: 0;
  transition: background 0.15s;
}

.nav-link-main {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: 1 1 auto;
  min-width: 0;
}

.nav-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  color: #606060;
}

.nav-link-icon svg {
  width: 24px;
  height: 24px;
}

.nav-link-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-link-meta {
  flex: 0 0 auto;
  margin-left: auto;
  text-align: right;
  font-size: 12px;
  font-weight: 400;
  color: #606060;
  line-height: 1;
}

.nav-link:hover {
  background: #f2f2f2;
  color: var(--text);
}

.nav-link[aria-current="page"] {
  background: var(--primary-subtle);
  font-weight: 600;
  color: var(--primary);
}

.nav-link[aria-current="page"] .nav-link-icon {
  color: var(--primary);
}

.nav-link[aria-current="page"] .nav-link-icon svg {
  stroke-width: 2.2;
}

.nav-link[aria-current="page"] .nav-link-meta {
  font-weight: 600;
  color: var(--primary);
}

.nav-link[aria-current="page"] .nav-link-badge--open {
  background: #f64c3b;
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.nav-link[aria-current="page"] .nav-link-badge--in-progress:not(.nav-link-badge--stacked-behind) {
  background: #ffb43d;
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.nav-link[aria-current="page"] .nav-link-badge--stacked-behind {
  background: #ffb43d;
  box-shadow: none;
}

.nav-link[aria-current="page"] .nav-link-badge--stacked-front {
  background: #f64c3b;
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.admin-content {
  min-width: 0;
  min-height: 0;
  max-width: none;
  width: 100%;
  margin: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  padding: 28px 32px;
  background: var(--surface-subtle);
}

.admin-content .hero,
.admin-content .layout {
  max-width: none;
}

.admin-page-toolbar {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  flex-wrap: wrap;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.hero h1 {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.lead {
  max-width: none;
  margin: 4px 0 0;
  color: var(--text-subtle);
  font-size: 13px;
  line-height: 1.6;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0;
}

.service-ja-row-actions {
  gap: 12px;
  align-items: center;
  padding: 2px 0;
}

.service-backup-row-actions {
  gap: 8px;
  align-items: center;
}

.service-backup-row-actions form {
  margin: 0;
}

.service-bams-archive-filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.service-bams-archive-filter-field {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.service-bams-archive-filter-label {
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 600;
}

.service-bams-archive-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.service-bams-archive-filter-actions .button,
.service-bams-archive-filter-actions button {
  min-height: 44px;
}

.backup-copy-button svg {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
}

.backup-copy-button--icon-only {
  padding: 10px;
  min-width: 0;
}

.action-row {
  display: flex;
  width: 100%;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.machine-csv-import-form {
  padding: 10px 14px;
  margin: 0;
  border-bottom: 1px solid var(--border);
}

.machine-csv-import-form--overflow {
  padding: 0;
  margin: 0;
  border: 0;
}

.machine-csv-overflow {
  position: relative;
  display: inline-flex;
  align-items: center;
}



.machine-csv-overflow-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: min(320px, calc(100vw - 32px));
  padding: 12px 14px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}

.machine-csv-overflow-panel[hidden] {
  display: none !important;
}

.machine-csv-overflow-heading {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.machine-csv-overflow-resource {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.machine-csv-overflow-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.machine-csv-overflow-actions .button,
.machine-csv-overflow-actions button,
.machine-csv-overflow-export {
  width: 100%;
  min-height: 40px;
  border-radius: 999px;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 9px 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(45, 93, 161, 0.3);
}

.button:hover,
button:hover {
  background: var(--primary-hover);
  box-shadow: 0 2px 6px rgba(45, 93, 161, 0.35);
}

.button:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
  box-shadow: none;
}

.button:disabled:hover,
button:disabled:hover {
  background: var(--primary);
  box-shadow: none;
}

.backup-job-button {
  min-width: 240px;
}

.backup-job-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: backup-spin 0.8s linear infinite;
}

@keyframes backup-spin {
  to {
    transform: rotate(360deg);
  }
}

.button-secondary {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--border);
  border-radius: 999px;
  box-shadow: none;
  font-weight: 500;
}

.button-secondary:hover {
  background: var(--primary-subtle);
  border-color: var(--primary);
  box-shadow: none;
}

.machine-csv-overflow-toggle {
  display: inline-grid;
  place-items: center;
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  padding: 0;
  border-radius: 50% !important;
  border: none;
  flex: 0 0 40px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  clip-path: circle(50% at 50% 50%);
  appearance: none;
  -webkit-appearance: none;
  background-clip: padding-box;
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border);
  box-shadow: none;
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
}

.machine-csv-overflow-toggle:hover,
.machine-csv-overflow-toggle:focus-visible {
  background: var(--primary-subtle);
  border-color: var(--primary);
  box-shadow: none;
}

button.user-avatar,
.user-avatar {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 999px;
  flex: 0 0 34px;
}

.user-avatar.user-avatar--large,
button.user-avatar.user-avatar--large {
  width: 48px;
  height: 48px;
  min-height: 48px;
  flex-basis: 48px;
}

.button-warm {
  background: var(--danger);
  box-shadow: none;
}

.button-warm:hover {
  background: #a50e0e;
}

.layout {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.card-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  align-items: start;
}

.jaconnect-link-layout {
  display: grid;
  gap: 18px;
}

.jaconnect-link-top {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 18px;
  align-items: start;
}

.jaconnect-link-stats {
  grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 14px;
  align-items: end;
}

.form-grid-full {
  grid-column: 1 / -1;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding-top: 22px;
}

.checkbox-field input[type="checkbox"] {
  min-height: 0;
}

.jaconnect-checkbox-copy {
  display: grid;
  gap: 4px;
}

.jaconnect-checkbox-copy small {
  color: var(--text-subtle);
  font-size: 12px;
  line-height: 1.55;
}

.jaconnect-settings-form {
  display: grid;
  gap: 16px;
}

.jaconnect-settings-field {
  display: grid;
  gap: 8px;
}

.jaconnect-settings-field small {
  color: var(--text-subtle);
  font-size: 12px;
  line-height: 1.55;
}

.jaconnect-method-details {
  display: grid;
}

.jaconnect-method-detail {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafbfc;
}

.jaconnect-method-detail[hidden],
.jaconnect-bams-suffix-field[hidden] {
  display: none;
}

.jaconnect-method-detail h3 {
  margin: 0;
  font-size: 15px;
}

.jaconnect-method-detail p {
  margin: 0;
}

.jaconnect-method-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.jaconnect-method-pair div {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface);
}

.jaconnect-method-pair dt {
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 600;
}

.jaconnect-method-pair dd {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.jaconnect-sync-status {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--success-subtle);
  border-radius: 10px;
  background: var(--success-subtle);
}

.jaconnect-sync-status-disabled {
  border-color: var(--warning-subtle);
  background: var(--warning-subtle);
}

.jaconnect-sync-status strong {
  font-size: 14px;
}

.jaconnect-sync-status p {
  margin: 0;
  color: var(--text-subtle);
  line-height: 1.55;
}

.jaconnect-sync-next-action {
  color: var(--text) !important;
  font-weight: 600;
}

.jaconnect-link-sync .actions {
  margin-top: 16px;
}

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

.jaconnect-farmer-cell,
.jaconnect-code-stack {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.jaconnect-link-table .jaconnect-reason-row td {
  padding-top: 0;
  border-bottom-color: #eeeeee;
  white-space: normal;
}

.jaconnect-link-table .jaconnect-reason-row:hover td {
  background: transparent !important;
}

.jaconnect-link-table tr:has(+ .jaconnect-reason-row) td {
  border-bottom: 0;
}

.jaconnect-reason-detail {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  max-width: 760px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fafbfc;
  color: var(--text-subtle);
  font-size: 12px;
  line-height: 1.55;
}

.jaconnect-reason-label {
  color: var(--text);
  font-weight: 700;
}

.jaconnect-inline-form {
  display: grid;
  grid-template-columns: minmax(128px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.jaconnect-inline-form input {
  min-width: 128px;
}

@media (max-width: 1180px) {
  .jaconnect-link-top {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .jaconnect-method-pair {
    grid-template-columns: 1fr;
  }
}

.card,
.panel,
.table-card,
.metric {
  background: var(--surface);
  border: none;
  box-shadow: var(--shadow-sm);
}

.card,
.panel,
.table-card {
  min-width: 0;
  padding: 22px;
  border-radius: 16px;
}

.metric {
  padding: 22px;
  border-radius: 16px;
}

.metric-value {
  display: block;
  margin-top: 10px;
  font-size: 30px;
  line-height: 1;
  font-weight: 700;
}

.metric-label,
.subtle {
  color: var(--text-subtle);
}

.card h2,
.panel h2,
.table-card h2 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.card p,
.panel p {
  margin: 0;
  color: var(--text-subtle);
  line-height: 1.65;
  font-size: 13px;
}

.stack {
  display: grid;
  gap: 14px;
}

.list {
  margin: 0;
  padding-left: 20px;
  color: var(--text-subtle);
}

.list li + li {
  margin-top: 6px;
}

.table,
.panel table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table-scroll {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  /* Y は clip（スクロールコンテナにしない）。横スクロールのみのラッパーでも一部引擎は computed を hidden と報告する。 */
  overflow-y: clip;
}

/* 一覧テーブルはプロジェクト全体で単一行表示に揃え、必要なら横スクロールさせる */
.table-scroll > table {
  width: 100%;
  min-width: max-content;
  max-width: none;
}

.table-scroll > table th,
.table-scroll > table td {
  white-space: nowrap;
}

.admin-table[data-admin-sticky-table-header] thead th,
.table.farmer-table[data-admin-sticky-table-header] thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  box-shadow: 0 1px 0 #eeeeee;
}

/* 無限スクロール付き一覧: sticky が効かない引擎向けに admin-table-sort.js が挿入するミラー用 */
.admin-infinite-sticky-mirror {
  display: none;
  position: fixed;
  z-index: 25;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}

/* 横スクロールは本体 .table-scroll の 1 本だけ見せる（Mac/Windows 共通で二重バーを避ける） */
.admin-infinite-sticky-mirror-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  pointer-events: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.admin-infinite-sticky-mirror-scroll::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.admin-infinite-sticky-mirror-table {
  margin: 0;
  border-collapse: collapse;
}

.admin-infinite-sticky-mirror-table tbody {
  display: none;
}

.table th,
.table td,
.panel table th,
.panel table td {
  padding: 12px 16px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid #eeeeee;
}

.table th,
.panel table th {
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

body.mobile-body .mobile-app .mobile-paper-card-body .table:not(:has(thead)) tbody td,
body.mobile-body .mobile-app .mobile-paper-card-body .mobile-record-title,
body.mobile-body .mobile-app .mobile-paper-card-body .mobile-record-meta dd {
  color: #d00000;
  font-weight: 700;
}

.table tbody tr:not(.farmer-row-selected):hover td,
.panel table tbody tr:not(.farmer-row-selected):hover td {
  background: #fafbfc;
}

.table tr:last-child th,
.table tr:last-child td,
.panel table tr:last-child th,
.panel table tr:last-child td {
  border-bottom: none;
}

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

/* 数値列: block + max-width のellipsisがセル左に残るのを防ぎ、右端に寄せる */
.table td.table-align-right > .admin-cell-ellipsis.admin-cell-num,
.panel table td.table-align-right > .admin-cell-ellipsis.admin-cell-num {
  margin-left: auto;
}

.farmer-table tbody tr {
  transition:
    background-color 120ms ease,
    color 120ms ease;
}

.farmer-table tbody tr.farmer-row-selected td {
  background: var(--primary);
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

/* 選択中もホバー中も背景をプライマリ�用 .table tbody tr:hover や .admin-row-link:hover より優先） */
.farmer-table tbody tr.farmer-row-selected:hover td {
  background: var(--primary);
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

/* BAMS 書類列はホ�用ルールの詳細度が高いため、選択+ホバー時もプライマリを��持 */
.farmer-table tbody tr.farmer-row-selected:hover td.bams-case-doc-cell--yes,
.farmer-table tbody tr.farmer-row-selected:hover td.bams-case-doc-cell--no {
  background: var(--primary);
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

.farmer-table tbody tr.farmer-row-selected a {
  color: #fff;
}

.farmer-table tbody tr.farmer-row-selected .bams-case-doc-action {
  color: #1f2937;
  background: #fff;
  border-color: #c7d2e3;
}

.farmer-table tbody tr.farmer-row-selected .bams-case-doc-action:hover,
.farmer-table tbody tr.farmer-row-selected .bams-case-doc-action:focus-visible {
  color: #172033;
  background: #eef3f9;
  border-color: #9fb3d8;
}

.farmer-table tbody tr.farmer-row-selected .subtle {
  color: rgba(255, 255, 255, 0.82);
}

.farmer-table tbody tr.farmer-row-selected .button.button-secondary {
  border-color: rgba(255, 255, 255, 0.78);
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.farmer-table tbody tr.farmer-row-selected .button.button-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
}

.mono {
  font-family: "SFMono-Regular", "SF Mono", Consolas, monospace;
}

.csv-preview-value-stack {
  display: inline-grid;
  gap: 6px;
  align-items: start;
}

.csv-preview-value {
  display: inline-block;
}

.csv-preview-old {
  color: var(--text-subtle);
  text-decoration: line-through;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--primary-subtle);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.filter-btn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-subtle);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-subtle);
}

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

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

.filter-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.filter-checkbox input[type="checkbox"] {
  min-height: 0;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.role-badge--admin {
  background: var(--primary-subtle);
  color: var(--primary);
}

.role-badge--staff {
  background: var(--success-subtle);
  color: var(--success);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.status-waiting {
  background: var(--warning-subtle);
  color: var(--warning);
}

.status-loaded {
  background: #e8f0fe;
  color: #1a73e8;
}

.status-transferring {
  background: #f3e8fd;
  color: #7b1fa2;
}

.status-transfer-waiting {
  background: #e6f4ea;
  color: #188038;
}

.status-inspected {
  background: #fde7f3;
  color: #ad1457;
}

.status-open {
  background: var(--danger-subtle);
  color: var(--danger);
}

.status-in-progress {
  background: var(--warning-subtle);
  color: var(--warning);
}

.status-resolved {
  background: var(--success-subtle);
  color: var(--success);
}

.notice,
.error {
  padding: 14px 16px;
  border-radius: 12px;
  font-weight: 600;
}

.notice {
  background: var(--success-subtle);
  color: var(--success);
}

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

.admin-toast {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top, 0px));
  right: 20px;
  z-index: 140;
  max-width: min(420px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 180ms ease, transform 180ms ease;
}

.admin-toast-notice {
  color: var(--primary);
  background: #fff;
  border: 1px solid rgba(45, 93, 175, 0.24);
}

.admin-toast-error {
  color: var(--danger);
  background: #fff;
  border: 1px solid rgba(197, 34, 31, 0.2);
}

.admin-toast-hidden {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

form {
  display: grid;
  gap: 14px;
}

.admin-filter-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

.admin-filter-grid > * {
  min-width: 0;
}

.admin-filter-grid input,
.admin-filter-grid select {
  width: 100%;
  min-width: 0;
}

.admin-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

/* 組合員一覧: 検索対象プルダウン → キーワード → 検索（荷受一覧のグリッドとは独立） */
.farmer-list-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
}

.farmer-list-filter-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.farmer-list-filter-field--scope {
  flex: 0 1 auto;
  width: min(100%, 280px);
}

.farmer-list-filter-field--keyword {
  flex: 1 1 220px;
  min-width: min(100%, 200px);
}

.farmer-list-filter-field--actions {
  flex: 0 0 auto;
}

.farmer-list-filter-field--checkbox {
  flex: 0 0 auto;
}

.farmer-list-filter-field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-subtle);
}

.farmer-list-filter-field-label--visually-empty {
  visibility: hidden;
  min-height: 1.2em;
}

.farmer-list-filter-field--scope select,
.farmer-list-filter-field--keyword input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
}

.farmer-list-filter-actions-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.bams-case-pending-filter {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.farmer-filter-form {
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 16px;
}

.farmer-filter-fields-panel,
.farmer-filter-actions-panel {
  border: 1px solid rgba(213, 222, 236, 0.92);
  border-radius: 24px;
}

.farmer-filter-fields-panel {
  padding: 18px;
  background: #f8fbff;
}

.farmer-filter-actions-panel {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 18px;
  background: #f3f7fd;
}

.farmer-filter-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.farmer-filter-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.farmer-filter-field--keyword {
  grid-column: 1 / span 2;
}

.farmer-filter-field input,
.farmer-filter-field select {
  width: 100%;
  min-width: 0;
}

.farmer-filter-range {
  display: grid;
  grid-column: 1 / span 2;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.farmer-filter-actions {
  width: 100%;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.farmer-filter-actions .button,
.farmer-filter-actions button {
  width: 100%;
  min-width: 0;
  justify-content: center;
}

@media (min-width: 1680px) {
  .farmer-filter-form {
    grid-template-columns: minmax(0, 1fr) 280px;
  }

  .farmer-filter-fields {
    grid-template-columns: minmax(240px, 1.6fr) repeat(4, minmax(140px, 1fr));
  }

  .farmer-filter-field--keyword {
    grid-column: 1 / 2;
  }

  .farmer-filter-range {
    grid-column: 1 / span 3;
  }
}

.admin-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-section-head__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.admin-hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.admin-filter-export-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
  margin-bottom: 12px;
}

.admin-summary-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
  margin-bottom: 12px;
  padding: 16px 20px;
}

.admin-summary-bar__primary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-right: 18px;
  border-right: 1px solid #d9e3f2;
  white-space: nowrap;
}

.admin-summary-bar__primary-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  align-items: flex-start;
}

.admin-summary-bar__primary-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
}

.admin-summary-bar__primary-caption {
  margin: 0;
  max-width: 42ch;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  white-space: normal;
}

.admin-summary-bar__primary-label {
  color: var(--text-subtle);
  font-size: 14px;
  font-weight: 700;
}

.admin-summary-bar__primary-value {
  color: var(--primary);
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 34px;
  line-height: 1;
}

.admin-summary-bar__primary-unit {
  color: var(--text-subtle);
  font-size: 0.48em;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.admin-summary-bar__stats {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  flex: 1;
}

.admin-summary-bar__stat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #fff;
  white-space: nowrap;
}

.admin-summary-bar__stat-label {
  color: var(--text-subtle);
  font-size: 13px;
  font-weight: 700;
}

.admin-summary-bar__stat-value {
  font-size: 16px;
}

.admin-summary-bar__export {
  display: flex;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.admin-collapsible {
  padding: 0;
  overflow: hidden;
}

.admin-collapsible-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
}

.admin-collapsible-summary::-webkit-details-marker {
  display: none;
}

.admin-collapsible-summary h2 {
  margin: 0;
}

.admin-collapsible-icon {
  width: 12px;
  height: 12px;
  border-right: 2px solid var(--text-subtle);
  border-bottom: 2px solid var(--text-subtle);
  transform: rotate(45deg);
  transition: transform 140ms var(--ease);
}

.admin-collapsible[open] .admin-collapsible-icon {
  transform: rotate(225deg);
}

.admin-collapsible-body {
  padding: 0 20px 20px;
}

@media (max-width: 1120px) {
  .admin-summary-bar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .admin-summary-bar__primary {
    border-right: none;
    padding-right: 0;
  }

  .admin-summary-bar__stats {
    width: 100%;
  }

  .admin-summary-bar__export {
    margin-left: auto;
  }

  .farmer-filter-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .farmer-filter-field--keyword,
  .farmer-filter-range {
    grid-column: 1 / -1;
  }

  .farmer-filter-actions {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .farmer-filter-actions .button,
  .farmer-filter-actions button {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 720px) {
  .admin-summary-bar {
    gap: 12px;
    padding: 14px 16px;
  }

  .admin-summary-bar__primary {
    width: 100%;
  }

  .admin-summary-bar__primary-value {
    font-size: 28px;
  }

  .admin-summary-bar__stats {
    gap: 8px;
  }

  .admin-summary-bar__stat {
    padding: 7px 10px;
  }

  .admin-summary-bar__export {
    width: 100%;
    justify-content: flex-end;
  }

  .farmer-filter-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .farmer-filter-range {
    grid-template-columns: 1fr;
  }

  .farmer-filter-actions {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .farmer-filter-actions .button,
  .farmer-filter-actions button {
    width: 100%;
    min-width: 0;
  }

  .farmer-filter-actions-panel,
  .farmer-filter-fields-panel {
    padding: 16px;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- BAMS dashboard --- */

.bams-dashboard {
  display: grid;
  gap: 18px;
  color: #202124;
}

.bams-dashboard-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 58px;
  padding: 12px 16px;
  border: 1px solid #dfe3e8;
  border-radius: 6px;
  background: #fff;
}

.bams-dashboard-context > div,
.bams-dashboard-context__update {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.bams-dashboard-context__label,
.bams-dashboard-context__update > span:first-child {
  color: #687078;
  font-size: 12px;
  font-weight: 600;
}

.bams-dashboard-context strong {
  font-size: 16px;
}

.bams-dashboard-context__update strong {
  font-size: 13px;
}

.bams-dashboard-campaign-status {
  background: #e8f0fe;
  color: #245aa1;
}

.bams-dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.bams-dashboard-kpi {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 116px;
  padding: 14px 14px 12px;
  overflow: hidden;
  border: 1px solid #dfe3e8;
  border-radius: 6px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.bams-dashboard-kpi:hover {
  border-color: #9db6d2;
  box-shadow: 0 3px 10px rgba(32, 65, 104, 0.1);
}

.bams-dashboard-kpi__label {
  color: #5f6368;
  font-size: 12px;
  font-weight: 700;
}

.bams-dashboard-kpi__value {
  align-self: center;
  margin-top: 4px;
  color: #1f3d61;
  font-size: 30px;
  font-weight: 750;
  line-height: 1;
}

.bams-dashboard-kpi__value small {
  margin-left: 3px;
  font-size: 12px;
  font-weight: 700;
}

.bams-dashboard-kpi__detail {
  overflow: hidden;
  color: #747b82;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bams-dashboard-main-grid,
.bams-dashboard-lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.8fr);
  gap: 14px;
  align-items: stretch;
}

.bams-dashboard-lower-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bams-dashboard-section {
  min-width: 0;
  padding: 18px;
  border: 1px solid #dfe3e8;
  border-radius: 8px;
  background: #fff;
}

.bams-dashboard-section__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.bams-dashboard-section__head span {
  display: block;
  margin-bottom: 3px;
  color: #737a82;
  font-size: 10px;
  font-weight: 700;
}

.bams-dashboard-section__head h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.bams-dashboard-section__head > a,
.bams-dashboard-section-link {
  color: #245f9e;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.bams-dashboard-section__head > a:hover,
.bams-dashboard-section-link:hover {
  text-decoration: underline;
}

.bams-dashboard-progress {
  display: flex;
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 3px;
  background: #edf0f3;
}

.bams-dashboard-progress__segment { min-width: 2px; }
.bams-dashboard-progress__segment--draft { background: #637d99; }
.bams-dashboard-progress__segment--review { background: #d28a24; }
.bams-dashboard-progress__segment--pending { background: #4b8fc9; }
.bams-dashboard-progress__segment--confirmed { background: #3e8d60; }
.bams-dashboard-progress__segment--ready { background: #268d8b; }
.bams-dashboard-progress__segment--submitted { background: #6b5ca5; }
.bams-dashboard-progress__segment--withdrawn { background: #9b9fa4; }
.bams-dashboard-progress__empty { width: 100%; }

.bams-dashboard-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid #e2e5e9;
  border-radius: 5px;
  background: #e2e5e9;
}

.bams-dashboard-status-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 45px;
  padding: 9px 10px;
  background: #fff;
  color: #353a40;
  font-size: 12px;
  text-decoration: none;
}

.bams-dashboard-status-item:hover { background: #f6f9fc; }
.bams-dashboard-status-item.is-empty { color: #8a9096; }
.bams-dashboard-status-item strong { font-size: 15px; }

.bams-dashboard-status-item__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9b9fa4;
}

.bams-dashboard-status-item__dot--draft { background: #637d99; }
.bams-dashboard-status-item__dot--review { background: #d28a24; }
.bams-dashboard-status-item__dot--pending { background: #4b8fc9; }
.bams-dashboard-status-item__dot--confirmed { background: #3e8d60; }
.bams-dashboard-status-item__dot--ready { background: #268d8b; }
.bams-dashboard-status-item__dot--submitted { background: #6b5ca5; }

.bams-dashboard-action-list,
.bams-dashboard-import-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bams-dashboard-action-list li + li,
.bams-dashboard-import-list li + li {
  border-top: 1px solid #e6e9ed;
}

.bams-dashboard-action-list a {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-height: 61px;
  padding: 8px 4px;
  color: inherit;
  text-decoration: none;
}

.bams-dashboard-action-list a:hover strong { color: #245f9e; }

.bams-dashboard-action-list__marker {
  width: 4px;
  height: 34px;
  border-radius: 2px;
  background: #4b8fc9;
}

.bams-dashboard-action-list__marker--danger { background: #b6423b; }
.bams-dashboard-action-list__marker--warning { background: #c47b12; }

.bams-dashboard-action-list__copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.bams-dashboard-action-list__copy strong { font-size: 13px; }
.bams-dashboard-action-list__copy small { color: #747b82; font-size: 11px; }
.bams-dashboard-action-list__count { color: #283f58; font-size: 19px; font-weight: 750; }
.bams-dashboard-action-list__count small { margin-left: 2px; font-size: 10px; }

.bams-dashboard-all-clear {
  display: grid;
  gap: 5px;
  min-height: 112px;
  align-content: center;
  padding: 18px;
  border: 1px solid #cfe3d6;
  border-radius: 6px;
  background: #f2f8f4;
  text-align: center;
}

.bams-dashboard-all-clear strong { color: #296a43; font-size: 15px; }
.bams-dashboard-all-clear span { color: #657269; font-size: 12px; }

.bams-dashboard-import-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 8px 0;
}

.bams-dashboard-import-list__main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  color: #646b72;
  font-size: 11px;
}

.bams-dashboard-import-list__year { color: #30363d; font-size: 13px; font-weight: 700; }
.bams-dashboard-import-list__issues { color: #a05f0c; font-weight: 700; }
.bams-dashboard-import-list__time { color: #757c83; font-size: 11px; white-space: nowrap; }
.bams-dashboard-import-status { padding: 3px 7px; border-radius: 4px; }
.bams-dashboard-import-status--succeeded { background: #e4f2e8; color: #276f43; }
.bams-dashboard-import-status--failed { background: #f9e3e1; color: #a43631; }
.bams-dashboard-import-status--needs-attention { background: #fff0d9; color: #985b09; }
.bams-dashboard-import-status--running { background: #e4eff9; color: #245f9e; }
.bams-dashboard-import-status--queued { background: #eceff2; color: #596168; }
.bams-dashboard-section-link { display: inline-block; margin-top: 12px; }

.bams-dashboard-year-table-wrap { overflow-x: auto; }

.bams-dashboard-year-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 12px;
}

.bams-dashboard-year-table th,
.bams-dashboard-year-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #e5e8eb;
  text-align: left;
  white-space: nowrap;
}

.bams-dashboard-year-table th {
  color: #6b737b;
  font-size: 11px;
  font-weight: 700;
}

.bams-dashboard-year-table tbody tr:last-child td { border-bottom: 0; }
.bams-dashboard-year-table .is-numeric { text-align: right; }
.bams-dashboard-year-table a { color: #245f9e; text-decoration: none; }
.bams-dashboard-year-table a:hover { text-decoration: underline; }

.bams-dashboard-empty {
  min-height: 70px;
  margin: 0;
  display: grid;
  place-items: center;
  color: #747b82;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .bams-dashboard-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bams-dashboard-status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 880px) {
  .bams-dashboard-main-grid,
  .bams-dashboard-lower-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .bams-dashboard-context,
  .bams-dashboard-context > div,
  .bams-dashboard-context__update {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .bams-dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bams-dashboard-kpi { min-height: 104px; }
  .bams-dashboard-kpi__value { font-size: 26px; }
  .bams-dashboard-section { padding: 14px; }
  .bams-dashboard-section__head { align-items: flex-start; flex-direction: column; gap: 6px; }
  .bams-dashboard-status-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .bams-dashboard-kpis { grid-template-columns: 1fr; }
  .bams-dashboard-import-list li { align-items: flex-start; flex-direction: column; gap: 3px; }
}

/* --- service BAMS dashboard --- */

.service-bams-dashboard {
  min-width: 0;
  padding: 18px;
  border: 1px solid #dfe3e8;
  border-radius: 8px;
  background: #fff;
}

.service-bams-dashboard__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.service-bams-dashboard__head span {
  display: block;
  margin-bottom: 3px;
  color: #737a82;
  font-size: 10px;
  font-weight: 700;
}

.service-bams-dashboard__head h2 {
  margin: 0;
  font-size: 18px;
}

.service-bams-dashboard__head p {
  margin: 0;
  color: #737a82;
  font-size: 11px;
}

.service-dashboard-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid #dfe3e8;
  border-radius: 6px;
  background: #fff;
}

.service-dashboard-summary > div {
  display: grid;
  min-height: 104px;
  align-content: center;
  padding: 13px 16px;
}

.service-dashboard-summary > div + div {
  border-left: 1px solid #dfe3e8;
}

.service-dashboard-summary span {
  color: #646b72;
  font-size: 11px;
  font-weight: 700;
}

.service-dashboard-summary strong {
  margin: 6px 0 4px;
  color: #213c59;
  font-size: 28px;
  line-height: 1;
}

.service-dashboard-summary strong small {
  margin-left: 3px;
  font-size: 11px;
}

.service-dashboard-summary p {
  margin: 0;
  color: #7a8086;
  font-size: 10px;
}

.service-dashboard-table-wrap {
  border: 1px solid #e1e4e8;
  border-radius: 6px;
}

.service-dashboard-table {
  min-width: 1140px;
  border-collapse: collapse;
}

.service-dashboard-table th {
  padding: 10px 11px;
  background: #f3f5f7;
  color: #596168;
  font-size: 11px;
  white-space: nowrap;
}

.service-dashboard-table td {
  padding: 11px;
  vertical-align: middle;
  font-size: 12px;
}

.service-dashboard-table tbody tr:hover {
  background: #f8fafc;
}

.service-dashboard-table td > small,
.service-dashboard-ja-slug {
  display: block;
  margin-top: 3px;
  color: #7a8086;
  font-size: 10px;
}

.service-dashboard-statuses {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 330px;
}

.service-dashboard-statuses > span {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 4px 6px;
  border: 1px solid #e0e4e8;
  border-radius: 4px;
  background: #fff;
  white-space: nowrap;
}

.service-dashboard-statuses small {
  color: #6e757c;
  font-size: 9px;
}

.service-dashboard-statuses strong {
  font-size: 12px;
}

.service-dashboard-number {
  text-align: right;
  white-space: nowrap;
}

.service-dashboard-number strong {
  font-size: 18px;
}

.service-dashboard-number small {
  margin-left: 2px;
  color: #737a82;
  font-size: 9px;
}

.service-dashboard-number--attention strong {
  color: #a65e08;
}

.service-dashboard-link-rate,
.service-dashboard-import {
  display: grid;
  gap: 3px;
  justify-items: start;
}

.service-dashboard-link-rate strong {
  font-size: 14px;
}

.service-dashboard-link-rate small,
.service-dashboard-import small,
.service-dashboard-import > span:nth-child(2) {
  color: #737a82;
  font-size: 9px;
  white-space: nowrap;
}

.service-dashboard-table .button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 11px;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .service-dashboard-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .service-dashboard-summary > div + div {
    border-left: 0;
  }

  .service-dashboard-summary > div:nth-child(even) {
    border-left: 1px solid #dfe3e8;
  }

  .service-dashboard-summary > div:nth-child(n + 3) {
    border-top: 1px solid #dfe3e8;
  }
}

@media (max-width: 520px) {
  .service-bams-dashboard { padding: 14px; }
  .service-bams-dashboard__head { align-items: flex-start; flex-direction: column; gap: 5px; }
  .service-dashboard-summary { grid-template-columns: 1fr; }
  .service-dashboard-summary > div { min-height: 86px; }
  .service-dashboard-summary > div:nth-child(even) { border-left: 0; }
  .service-dashboard-summary > div + div { border-top: 1px solid #dfe3e8; }
}

/* --- flow graph (server-rendered SVG) --- */

.fg-panel-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dashboard-flow-stack {
  display: grid;
  gap: 20px;
}

.dashboard-flow-panel {
  display: grid;
  gap: 16px;
}

.dashboard-flow-panel__head [data-dashboard-flow-title] {
  user-select: none;
}

.dashboard-flow-visual {
  display: grid;
  gap: 0;
}

.dashboard-flow-visual__diagram {
  min-width: 0;
}

.dashboard-flow-visual__diagram--3d {
  position: relative;
  border: 1px solid #dbe4ef;
  border-radius: 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(66, 133, 244, 0.12), transparent 32%),
    radial-gradient(circle at top right, rgba(22, 163, 74, 0.12), transparent 28%),
    linear-gradient(180deg, #f8fbff 0%, #eef4fb 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.dashboard-flow-3d-stage {
  position: relative;
  min-height: clamp(320px, 42vw, 520px);
}

.dashboard-flow-3d-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.dashboard-flow-3d-fallback {
  position: relative;
  min-height: inherit;
  height: 100%;
  overflow: hidden;
}

.dashboard-flow-3d-fallback__space,
.dashboard-flow-3d-fallback__edges {
  position: absolute;
  inset: 0;
}

.dashboard-flow-3d-fallback__space {
  perspective: 1400px;
  transform-style: preserve-3d;
}

.dashboard-flow-3d-fallback__edges {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.dashboard-flow-3d-fallback__node {
  position: absolute;
  width: 220px;
  min-height: 108px;
  padding: 18px 20px 20px;
  border: 1px solid rgba(207, 219, 232, 0.95);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 36px rgba(48, 78, 120, 0.16);
  transform:
    translate3d(-50%, -50%, calc(var(--depth, 0) * 48px))
    rotateX(14deg)
    rotateY(-18deg);
  transform-style: preserve-3d;
  animation: dashboard-flow-fallback-float 5.6s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

.dashboard-flow-3d-fallback__node h3 {
  margin: 0 0 14px;
  font-size: 24px;
  line-height: 1.2;
}

.dashboard-flow-3d-fallback__status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 14px;
}

.dashboard-flow-3d-fallback__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.dashboard-flow-3d-fallback__label {
  color: #64748b;
}

.dashboard-flow-3d-fallback__count {
  font-size: 14px;
}

.dashboard-flow-3d-fallback__badge {
  position: absolute;
  right: 16px;
  bottom: 14px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: #2d5da1;
  color: #fff;
  font-weight: 700;
}

.dashboard-flow-3d-empty {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 24px rgba(22, 33, 56, 0.12);
}

@keyframes dashboard-flow-fallback-float {
  0%, 100% {
    transform:
      translate3d(-50%, -50%, calc(var(--depth, 0) * 48px))
      rotateX(14deg)
      rotateY(-18deg)
      translateY(0);
  }
  50% {
    transform:
      translate3d(-50%, -50%, calc(var(--depth, 0) * 48px))
      rotateX(14deg)
      rotateY(-18deg)
      translateY(-8px);
  }
}

.dashboard-flow-panel__head {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.dashboard-flow-panel__head h2 {
  margin-bottom: 0;
}

.dashboard-history-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
}

.dashboard-history-block {
  display: grid;
  gap: 6px;
}

.dashboard-history-item {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding-top: 6px;
  border-top: 1px solid #edf1f6;
  font-size: 12px;
  line-height: 1.35;
}

.dashboard-history-time {
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dashboard-history-copy,
.dashboard-history-main,
.dashboard-history-detail {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-history-copy {
  display: block;
}

.dashboard-history-main {
  font-weight: 700;
}

.dashboard-history-detail {
  color: var(--text-subtle);
}

.dashboard-history-more {
  display: grid;
  gap: 6px;
}

.dashboard-history-more > .dashboard-history-list--more {
  order: 1;
}

.dashboard-history-more__summary {
  order: 2;
  width: fit-content;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid #d7dee9;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  list-style: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  box-shadow: var(--shadow-xs);
}

.dashboard-history-more__summary::-webkit-details-marker {
  display: none;
}

.dashboard-history-more__label--open,
.dashboard-history-more[open] .dashboard-history-more__label--closed {
  display: none;
}

.dashboard-history-more[open] .dashboard-history-more__label--open {
  display: inline;
}

.dashboard-history-list--more .dashboard-history-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.fg-diagram {
  display: block;
  width: 100%;
  height: auto;
  font-family: system-ui, -apple-system, sans-serif;
}

.fg-node-bg {
  fill: #fff;
  stroke: #d0d7de;
  stroke-width: 1.2;
}

a:hover .fg-node-bg {
  stroke: #4a7dff;
  stroke-width: 1.8;
}

.admin-section-head h2 {
  margin-bottom: 6px;
}

/* 管理一覧: コンテナ（ブラウザ幅）に合わせて広げるが、内容幅未満には縮めない */
.table.admin-table {
  width: 100%;
  min-width: max-content;
  max-width: none;
}

.admin-table th,
.admin-table td {
  vertical-align: top;
  white-space: nowrap;
}

.admin-table th {
  white-space: nowrap;
}

.admin-cell-ellipsis {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-cell-pre-wrap {
  white-space: pre-wrap !important;
}

.admin-cell-w-xs {
  max-width: 56px;
}

.admin-cell-w-sm {
  max-width: 104px;
}

.admin-cell-w-md {
  max-width: 132px;
}

.admin-cell-w-lg {
  max-width: 180px;
}

.admin-cell-w-xl {
  max-width: 240px;
}

/* BAMS 案件一覧: 対象書類列（対象外はセル全体で穴あき感） */
.admin-table td.bams-case-doc-cell {
  text-align: center;
  vertical-align: middle;
  padding: 8px 6px;
  min-width: 7.5rem;
}

.admin-table td.bams-case-doc-cell + td.bams-case-doc-cell {
  border-left: 2px solid color-mix(in srgb, var(--primary) 22%, var(--border-subtle, #d0d4da));
}

.admin-table td.bams-case-doc-cell--yes {
  background: var(--success-subtle);
  color: var(--success);
  font-weight: 600;
}

.admin-table td.bams-case-doc-cell--no {
  background: repeating-linear-gradient(
    -36deg,
    var(--surface-subtle, #e8eaed),
    var(--surface-subtle, #e8eaed) 5px,
    color-mix(in srgb, var(--surface-subtle, #e8eaed) 72%, #c5cad3) 5px,
    color-mix(in srgb, var(--surface-subtle, #e8eaed) 72%, #c5cad3) 10px
  );
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border-subtle, #d0d4da) 55%, transparent);
}

.bams-case-doc-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  align-items: center;
}

.bams-case-doc-actions--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.bams-case-doc-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 6px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #1f2937;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.bams-case-doc-action:hover,
.bams-case-doc-action:focus-visible {
  border-color: #bfdbfe;
  background: #f8fafc;
  text-decoration: none;
}

.bams-case-doc-action[aria-busy="true"] {
  opacity: 0.7;
  pointer-events: none;
}

.bams-admin-document-modal-open {
  overflow: hidden;
}

.bams-admin-document-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.36);
}

.bams-admin-document-modal-window {
  width: 95vw;
  height: min(1080px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.34);
}

.bams-admin-document-modal-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  padding: max(0.55rem, env(safe-area-inset-top)) 0.55rem 0.55rem 0.9rem;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
}

.bams-admin-document-modal-title {
  margin: 0;
  min-width: 0;
  color: #111827;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.35;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bams-admin-document-modal-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  min-width: 0;
}

.bams-admin-document-variant-switch {
  grid-column: 1 / -1;
  display: inline-flex;
  justify-self: start;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  background: #fff;
}

.bams-admin-document-variant-switch button {
  min-width: 7.5rem;
  min-height: 34px;
  padding: 0.35rem 0.75rem;
  border: 0;
  border-right: 1px solid #cbd5e1;
  border-radius: 0;
  background: #fff;
  color: #334155;
  box-shadow: none;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.bams-admin-document-variant-switch button:last-child {
  border-right: 0;
}

.bams-admin-document-variant-switch button:hover,
.bams-admin-document-variant-switch button:focus-visible {
  background: #eff6ff;
  color: #1d4f91;
}

.bams-admin-document-variant-switch button.is-active {
  background: #1d5fa7;
  color: #fff;
}

.bams-admin-document-layout-edit-button {
  min-height: 32px;
  padding: 0.3rem 0.7rem;
  white-space: nowrap;
}

.bams-admin-document-modal-close {
  width: 38px;
  height: 38px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #6b7280;
  box-shadow: none;
}

.bams-admin-document-modal-close:hover,
.bams-admin-document-modal-close:focus-visible {
  background: #f3f4f6;
}

.bams-admin-document-modal-close svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bams-admin-document-modal-body {
  position: relative;
  min-height: 0;
  background: #f8fafc;
}

.bams-admin-document-modal-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}

.bams-admin-document-modal-status {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #f8fafc;
}

.bams-admin-document-modal-status[hidden] {
  display: none;
}

.bams-admin-document-status-card {
  width: min(520px, 100%);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  padding: 24px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  text-align: left;
}

.bams-admin-document-status-title {
  margin: 0 0 10px;
  color: #111827;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

.bams-admin-document-status-text {
  margin: 0 0 16px;
  color: #4b5563;
  font-size: 16px;
  line-height: 1.6;
  text-align: center;
}

.bams-admin-document-status-details {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #f3f4f6;
}

.bams-admin-document-status-details div {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr);
  gap: 10px;
}

.bams-admin-document-status-details dt {
  color: #6b7280;
  font-size: 13px;
  font-weight: 700;
}

.bams-admin-document-status-details dd {
  margin: 0;
  color: #111827;
  font-size: 13px;
  line-height: 1.5;
}

.bams-admin-document-status-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 14px;
  line-height: 1.5;
}

.bams-admin-document-status-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.bams-admin-document-status-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #1f2937;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.bams-admin-document-status-button:hover,
.bams-admin-document-status-button:focus-visible {
  border-color: #bfdbfe;
  background: #f8fafc;
  text-decoration: none;
}

@media (max-width: 840px) {
  .bams-admin-document-modal {
    padding: 12px;
  }

  .bams-admin-document-modal-window {
    width: 95vw;
    height: calc(100vh - 24px);
  }

  .bams-admin-document-variant-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .bams-admin-document-variant-switch button {
    min-width: 0;
    padding-inline: 0.4rem;
  }

  .bams-admin-document-variant-switch button:nth-child(2) {
    border-right: 0;
  }

  .bams-admin-document-variant-switch button:nth-child(-n + 2) {
    border-bottom: 1px solid #cbd5e1;
  }
}

.bams-case-mobile-actions {
  justify-content: flex-start;
  gap: 6px;
  flex-wrap: nowrap;
}

.bams-case-mobile-actions .button {
  white-space: nowrap;
}

.admin-table td.bams-case-jaconnect-cell {
  min-width: 7.5rem;
  text-align: center;
  vertical-align: middle;
}

.bams-case-jaconnect-link {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.bams-case-jaconnect-status-row {
  display: inline-grid;
  grid-template-columns: 9px auto 9px;
  align-items: center;
  column-gap: 7px;
}

.bams-case-jaconnect-status-row::before {
  width: 9px;
  content: "";
}

.bams-case-jaconnect-cache-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface-subtle);
}

.bams-case-jaconnect-cache-dot.is-checking {
  border-top-color: var(--primary);
  animation: bams-cache-dot-spin 0.8s linear infinite;
}

.bams-case-jaconnect-cache-dot.is-available {
  border-color: var(--success);
  background: var(--success);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--success) 18%, transparent);
}

.bams-case-jaconnect-cache-dot.is-missing {
  border-color: var(--text-subtle);
  background: transparent;
}

.bams-case-jaconnect-cache-dot.is-error {
  border-color: var(--danger);
  background: var(--danger-subtle);
}

@keyframes bams-cache-dot-spin {
  to { transform: rotate(360deg); }
}

.bams-case-jaconnect-status {
  min-width: 4.5rem;
  padding: 3px 8px;
  border: 1px solid transparent;
  text-decoration: none;
}

.bams-case-jaconnect-status--linked {
  background: var(--success-subtle);
  color: var(--success);
}

.bams-case-jaconnect-status--unlinked {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  background: var(--danger-subtle);
  color: var(--danger);
}

.bams-case-jaconnect-status--unlinked:hover,
.bams-case-jaconnect-status--unlinked:focus-visible {
  border-color: var(--danger);
  text-decoration: none;
}

.bams-case-jaconnect-code {
  font-size: 11px;
  color: var(--text-subtle);
  white-space: nowrap;
}

.farmer-table tbody tr.farmer-row-selected .bams-case-jaconnect-status,
.farmer-table tbody tr.farmer-row-selected .bams-case-jaconnect-status:hover,
.farmer-table tbody tr.farmer-row-selected .bams-case-jaconnect-status:focus-visible {
  border-color: #fff;
  background: #fff;
}

.farmer-table tbody tr.farmer-row-selected .bams-case-jaconnect-status--linked {
  color: var(--success);
}

.farmer-table tbody tr.farmer-row-selected .bams-case-jaconnect-status--unlinked {
  color: var(--danger);
}

.farmer-table tbody tr.farmer-row-selected .bams-case-jaconnect-code {
  color: rgba(255, 255, 255, 0.88);
}

.admin-table td.bams-case-status-cell {
  min-width: 5.5rem;
  text-align: center;
  vertical-align: middle;
  font-weight: 400;
}

.admin-table td.bams-case-status-cell--success {
  background: #5bc900;
  color: #fff;
}

.admin-table td.bams-case-status-cell--warning {
  background: #ffad1f;
  color: #fff;
}

.admin-table td.bams-case-status-cell--danger {
  background: #ff6259;
  color: #fff;
}

.admin-table td.bams-case-status-cell--neutral {
  background: #32b6e9;
  color: #fff;
}

.bams-case-status-main {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.bams-case-status-device {
  display: inline-flex;
  justify-content: center;
  flex: 0 0 auto;
}

.bams-confirm-device {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 30px;
  color: var(--primary);
}

@font-face {
  font-family: "JaconnectDeviceIcons";
  src: url("/public/fonts/jaconnect-device-icons.woff") format("woff");
  font-style: normal;
  font-weight: 400;
  font-display: block;
}

.bams-confirm-device__kind,
.bams-confirm-device__platform {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: #fff;
  color: var(--primary);
}

.bams-confirm-device__kind--desktop {
  color: #355a86;
}

.bams-confirm-device__kind--tablet {
  color: #4a6078;
}

.bams-confirm-device__kind--unknown {
  color: var(--muted);
}

.bams-confirm-device__platform--android {
  color: #a4c639;
}

.bams-confirm-device__platform--apple,
.bams-confirm-device__platform--windows {
  color: #1c7cf2;
}

.bams-confirm-device__kind svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.bams-confirm-device__brand {
  font-family: "JaconnectDeviceIcons";
  font-size: 18px;
  font-style: normal;
  font-weight: 400;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.bams-confirm-device__brand--apple::before {
  content: "\eabe";
}

.bams-confirm-device__brand--android::before {
  content: "\eac0";
}

.bams-confirm-device__brand--windows::before {
  content: "\eac2";
}

.admin-cell-w-date {
  max-width: 132px;
}

.admin-cell-w-guid {
  max-width: 96px;
}

.table td.admin-cell-num,
.panel table td.admin-cell-num,
.admin-cell-ellipsis.admin-cell-num {
  text-align: right;
}

.admin-cell-ellipsis mark {
  padding: 0 2px;
  border-radius: 4px;
  background: #fff1a8;
  color: inherit;
}

.admin-filter-match {
  display: inline-block;
  max-width: 100%;
  padding: 0 2px;
  border-radius: 4px;
  background: #fff1a8;
}

.admin-cell-icon {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.admin-checkmark {
  display: inline-block;
  width: 22px;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1.5px solid var(--text);
  background-color: #fff;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath d='M1 5.5 4.1 8.5 11 1.5' fill='none' stroke='%232d5da1' stroke-width='2.1' stroke-linecap='square' stroke-linejoin='miter'/%3E%3C/svg%3E");
}

.admin-row-link {
  cursor: pointer;
}

/* 行ホバーは書類列以外にのみ適用（対象セルの��／ストライプが消えないようにする） */
.admin-row-link:not(.farmer-row-selected):hover td:not(.bams-case-doc-cell):not(.bams-case-status-cell) {
  background: rgba(45, 93, 161, 0.04);
}

.admin-table tr.admin-row-link:not(.farmer-row-selected):hover td.bams-case-doc-cell--yes {
  background: color-mix(in srgb, var(--success-subtle) 82%, var(--success) 18%);
  color: var(--success);
}

.admin-table tr.admin-row-link:not(.farmer-row-selected):hover td.bams-case-doc-cell--no {
  background: repeating-linear-gradient(
    -36deg,
    color-mix(in srgb, var(--surface-subtle, #e8eaed) 58%, #c8cdd4),
    color-mix(in srgb, var(--surface-subtle, #e8eaed) 58%, #c8cdd4) 5px,
    color-mix(in srgb, var(--surface-subtle, #e8eaed) 70%, #b8bec8) 5px,
    color-mix(in srgb, var(--surface-subtle, #e8eaed) 70%, #b8bec8) 10px
  );
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border-subtle, #d0d4da) 55%, var(--primary) 12%);
}

.admin-table tr.admin-row-link:not(.farmer-row-selected):hover td.bams-case-status-cell--success {
  background: color-mix(in srgb, #5bc900 92%, #000);
  color: #fff;
}

.admin-table tr.admin-row-link:not(.farmer-row-selected):hover td.bams-case-status-cell--warning {
  background: color-mix(in srgb, #ffad1f 92%, #000);
  color: #fff;
}

.admin-table tr.admin-row-link:not(.farmer-row-selected):hover td.bams-case-status-cell--danger {
  background: color-mix(in srgb, #ff6259 92%, #000);
  color: #fff;
}

.admin-table tr.admin-row-link:not(.farmer-row-selected):hover td.bams-case-status-cell--neutral {
  background: color-mix(in srgb, #32b6e9 92%, #000);
  color: #fff;
}

.admin-row-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.form-fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.form-fieldset legend {
  padding: 0 4px;
  font-weight: 700;
}

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

.checkbox-row input[type="radio"],
.checkbox-row input[type="checkbox"] {
  min-height: 0;
}

select,
textarea,
input {
  min-height: 44px;
  padding: 0 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  /* label { font-weight: 700 } 配下でも入力文字は通常字重にする */
  font-weight: 400;
}

select:focus,
textarea:focus,
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(45, 93, 161, 0.14);
}

select:disabled,
textarea:disabled,
input:disabled {
  color: var(--text-muted, #888);
  background: var(--bg-muted, #f0f0f0);
  border-color: var(--border, #ddd);
  cursor: not-allowed;
}

textarea {
  min-height: 44px;
  padding: 10px 14px;
  line-height: 1.5;
  resize: none;
  overflow: hidden;
}

.file-input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.file-input-trigger {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.file-input-control {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.farmer-check {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  box-sizing: border-box;
  width: 22px;
  min-width: 22px;
  max-width: 22px;
  height: 22px;
  min-height: 22px;
  max-height: 22px;
  aspect-ratio: 1 / 1;
  padding: 0;
  margin: 0;
  border-radius: 999px;
  border: 1.5px solid #9fb3d8;
  background: #fff;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.94);
  cursor: pointer;
  transition:
    border-color 120ms ease,
    background-color 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
}

.farmer-table th:first-child,
.farmer-table td:first-child {
  width: 52px;
}

.farmer-check:hover {
  border-color: #7a9bcb;
  box-shadow:
    0 0 0 4px rgba(45, 93, 161, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.94);
}

.farmer-check:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 4px rgba(45, 93, 161, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.94);
}

.farmer-check:checked {
  border-color: var(--text);
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath d='M1 5.5 4.1 8.5 11 1.5' fill='none' stroke='%232d5da1' stroke-width='2.1' stroke-linecap='square' stroke-linejoin='miter'/%3E%3C/svg%3E");
}

.farmer-check:indeterminate {
  border-color: var(--text);
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath d='M2 5h8' fill='none' stroke='%232d5da1' stroke-width='2.1' stroke-linecap='square'/%3E%3C/svg%3E");
}

tr:has(.farmer-check) {
  cursor: pointer;
}

tr:has(.farmer-check):hover {
  background: var(--bg-hover, rgba(26, 115, 232, 0.04));
}

.farmer-card-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
  font-size: 14px;
}

#bams-case-bulk-bar {
  justify-content: flex-start;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

#bams-case-bulk-bar > span,
#bams-case-bulk-bar .button {
  flex-shrink: 0;
  white-space: nowrap;
}

.bams-jaconnect-zip-progress {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.bams-jaconnect-zip-progress[hidden] {
  display: none;
}

.bams-jaconnect-zip-progress::before {
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-top-color: var(--primary);
  border-radius: 50%;
  content: "";
  animation: bams-jaconnect-zip-spin 0.8s linear infinite;
}

.bams-jaconnect-zip-progress.is-complete::before {
  width: 14px;
  height: 14px;
  border: 0;
  color: var(--success, #16803a);
  content: "\2713";
  font-size: 15px;
  line-height: 14px;
  animation: none;
}

.bams-jaconnect-zip-progress-modal-open {
  overflow: hidden;
}

.bams-jaconnect-zip-progress-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(15 23 42 / 52%);
}

.bams-jaconnect-zip-progress-modal-window {
  width: min(100%, 540px);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 28px;
  border: 1px solid #d9e0ea;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 50px rgb(15 23 42 / 24%);
  text-align: center;
}

.bams-jaconnect-zip-progress-modal-spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 16px;
  border: 4px solid color-mix(in srgb, var(--primary) 22%, transparent);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: bams-jaconnect-zip-spin 0.8s linear infinite;
}

.bams-jaconnect-zip-progress-modal.is-error .bams-jaconnect-zip-progress-modal-spinner {
  border: 0;
  color: var(--danger, #b42318);
  font-size: 32px;
  line-height: 36px;
  animation: none;
}

.bams-jaconnect-zip-progress-modal.is-cancelled .bams-jaconnect-zip-progress-modal-spinner {
  display: none;
}

.bams-jaconnect-zip-progress-modal.is-error .bams-jaconnect-zip-progress-modal-spinner::before {
  content: "!";
}

.bams-jaconnect-zip-progress-modal-window h2 {
  margin: 0 0 14px;
  font-size: 21px;
  line-height: 1.4;
}

.bams-jaconnect-zip-progress-modal-message {
  margin: 0;
  color: #344054;
  line-height: 1.7;
}

.bams-jaconnect-zip-progress-modal-count {
  margin: 18px 0 8px;
  color: var(--primary);
  font-size: 18px;
  font-weight: 700;
}

.bams-jaconnect-zip-progress-modal.is-error .bams-jaconnect-zip-progress-modal-count {
  color: var(--danger, #b42318);
}

.bams-jaconnect-zip-progress-modal-bar {
  display: block;
  width: 100%;
  height: 12px;
  accent-color: var(--primary);
}

.bams-jaconnect-zip-progress-modal-estimate,
.bams-jaconnect-zip-progress-modal-eta,
.bams-jaconnect-zip-progress-modal-note {
  margin: 10px 0 0;
  color: #667085;
  font-size: 13px;
}

.bams-jaconnect-zip-progress-modal-eta {
  color: var(--text);
  font-weight: 700;
}

.bams-jaconnect-zip-progress-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 22px;
}

.button.bams-jaconnect-zip-cancel {
  border: 1px solid color-mix(in srgb, var(--danger) 88%, #000);
  background: var(--danger);
  color: #fff;
}

.button.bams-jaconnect-zip-cancel:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--danger) 78%, #000);
  background: color-mix(in srgb, var(--danger) 86%, #000);
  color: #fff;
}

.button.bams-jaconnect-zip-cancel:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

.bams-jaconnect-zip-package-modal-open {
  overflow: hidden;
}

.bams-jaconnect-zip-package-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(15 23 42 / 52%);
}

.bams-jaconnect-zip-package-modal-window {
  width: min(100%, 560px);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 24px;
  border: 1px solid #d9e0ea;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 50px rgb(15 23 42 / 24%);
}

.bams-jaconnect-zip-package-modal-window h2 {
  margin: 0 0 16px;
  font-size: 20px;
  line-height: 1.4;
}

.bams-jaconnect-zip-package-modal-warning {
  margin: 0 0 10px;
  color: #b42318;
  font-weight: 700;
}

.bams-jaconnect-zip-package-modal-file {
  overflow-wrap: anywhere;
  margin: 0 0 18px;
  padding: 10px 12px;
  border: 1px solid #d9e0ea;
  border-radius: 6px;
  background: #f7f9fc;
  color: #344054;
  font-size: 13px;
}

.bams-jaconnect-zip-package-modal-window ol {
  margin: 0;
  padding-left: 24px;
}

.bams-jaconnect-zip-package-modal-window li + li {
  margin-top: 10px;
}

.bams-jaconnect-zip-package-modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
}

@media (max-width: 640px) {
  .bams-jaconnect-zip-progress-modal,
  .bams-jaconnect-zip-package-modal {
    padding: 16px;
  }

  .bams-jaconnect-zip-progress-modal-window,
  .bams-jaconnect-zip-package-modal-window {
    max-height: calc(100vh - 32px);
    padding: 20px;
  }
}

@keyframes bams-jaconnect-zip-spin {
  to {
    transform: rotate(360deg);
  }
}

.button.admin-bulk-delete-btn {
  background: var(--danger);
  color: #fff;
  border: 1px solid color-mix(in srgb, var(--danger) 88%, #000);
  box-shadow: 0 1px 2px rgba(197, 34, 31, 0.22);
}

.button.admin-bulk-delete-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 86%, #000);
  border-color: color-mix(in srgb, var(--danger) 78%, #000);
  color: #fff;
}

.button.admin-bulk-delete-btn:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

.top-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.top-links a {
  color: var(--primary);
  font-weight: 500;
}

dialog {
  width: min(1080px, calc(100vw - 24px));
  max-height: min(88vh, 920px);
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: transparent;
}

dialog::backdrop {
  background: rgba(32, 33, 36, 0.38);
}

.app-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(32, 33, 36, 0.28);
  backdrop-filter: blur(4px);
}

.app-modal-wide .modal-card {
  width: min(1040px, calc(100vw - 32px));
}

.app-modal-bams-import-detail .modal-card {
  width: min(1360px, calc(100vw - 32px));
}

.modal-card {
  width: min(760px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
}

.modal-header {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.modal-header p {
  margin: 8px 0 0;
  color: var(--text-subtle);
  font-size: 13px;
  line-height: 1.6;
}

.modal-body {
  padding: 24px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.bams-import-job-detail-content {
  overflow-wrap: anywhere;
}

.bams-import-job-detail-content .table-scroll {
  overflow-x: visible;
}

.bams-import-job-detail-content .table-scroll > table {
  min-width: 0;
  max-width: 100%;
  table-layout: fixed;
}

.bams-import-job-detail-content .table-scroll > table th,
.bams-import-job-detail-content .table-scroll > table td {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bams-import-job-detail-content .mono {
  white-space: normal;
  overflow-wrap: anywhere;
}

.farmer-detail-report-links-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  overflow-x: auto;
  max-width: 100%;
  padding-bottom: 2px;
}

.farmer-detail-report-pdf-link {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.farmer-detail-report-pdf-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  line-height: 0;
}

.farmer-detail-report-pdf-icon-svg {
  display: block;
  width: auto;
  height: 1.55em;
  flex-shrink: 0;
}

.farmer-login-mobile-url-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.farmer-login-mobile-url-link:hover {
  color: var(--primary-dark);
}

.farmer-login-mobile-url-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 4px;
}

.farmer-login-temporary-note {
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 13px;
  line-height: 1.6;
}

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

.account-password-field--with-toggle {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.account-password-generate {
  white-space: nowrap;
}

.account-password-visibility-toggle {
  min-width: 42px;
  padding-inline: 10px;
}

.account-password-visibility-toggle svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.account-password-visibility-toggle.is-visible {
  background: var(--primary-subtle);
}

@media (max-width: 720px) {
  .account-password-field {
    grid-template-columns: 1fr;
  }

  .account-password-field--with-toggle {
    grid-template-columns: 1fr auto auto;
  }
}

.csv-preview-modal-body {
  display: grid;
  gap: 16px;
  align-content: start;
}

.csv-preview-modal-body .modal-footer {
  padding: 0;
}

.csv-preview-modal-body .action-row {
  margin: 0;
}

.csv-preview-more-label {
  margin: 12px 0 0;
  color: var(--text-subtle);
  font-size: 13px;
  font-weight: 600;
}

.modal-footer {
  flex-shrink: 0;
  padding: 0;
  margin-top: 16px;
}

.modal-footer .button,
.modal-footer button:not(.machine-modal-trash) {
  border-radius: 999px;
}

.modal-action-footer {
  display: flex;
  flex-direction: row-reverse;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modal-action-footer__main {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.modal-close-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -6px -10px -6px 8px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
}

.modal-close-icon:hover {
  color: var(--text);
  background: var(--surface-subtle);
}

.modal-close-icon:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.modal-close-icon svg {
  display: block;
}

.machine-modal-trash {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--danger) 88%, #000);
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(197, 34, 31, 0.22);
}

.machine-modal-trash:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 86%, #000);
  color: #fff;
}

.machine-modal-trash:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

.machine-modal-trash svg {
  display: block;
  stroke: #fff;
}

.dialog-card {
  overflow: auto;
  max-height: inherit;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 18px 48px rgba(26, 115, 232, 0.16);
}

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

.dialog-header h2 {
  margin: 0 0 6px;
}

.print-button {
  position: fixed;
  top: 16px;
  right: 16px;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
}

.sheet {
  width: min(840px, 100%);
  margin: 0 auto;
}

.page-break {
  page-break-before: always;
}

.label-card,
.slip-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
}

.label-card {
  min-height: calc(100vh - 80px);
  padding: 28px;
  display: grid;
  gap: 16px;
  justify-items: center;
  align-content: center;
  text-align: center;
}

.label-id {
  font-size: 30px;
  font-weight: 800;
}

.label-qr img {
  width: 220px;
  height: 220px;
}

.label-title {
  font-size: 26px;
  font-weight: 800;
}

.label-line {
  font-size: 19px;
}

.label-date,
.label-pager {
  color: var(--text-subtle);
  font-size: 15px;
}

.slip-card {
  padding: 28px;
  display: grid;
  gap: 18px;
}

.slip-title {
  font-size: 30px;
  font-weight: 800;
  text-align: center;
}

.slip-grid {
  display: grid;
  gap: 10px;
}

.slip-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dotted var(--border-strong);
}

.slip-label {
  color: var(--text-subtle);
  font-weight: 700;
}

.slip-value {
  font-weight: 700;
}

.slip-barcode {
  display: grid;
  gap: 8px;
  justify-items: center;
  margin-top: 12px;
}

.slip-barcode img {
  max-width: 100%;
}

.slip-barcode-text {
  letter-spacing: 0.24em;
  font-size: 16px;
  font-family: "SFMono-Regular", Consolas, monospace;
}

@media print {
  .no-print {
    display: none;
  }
}

@media (max-width: 720px) {
  main {
    padding: 20px 14px 60px;
  }

  .admin-topbar {
    height: 56px;
    padding: 0 14px;
  }

  .admin-sidebar-toggle {
    display: inline-flex;
  }

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

  .admin-sidebar-resizer {
    display: none;
  }

  .admin-sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    z-index: 80;
    width: min(320px, 86vw);
    border-right: 1px solid #e5e5e5;
    border-bottom: none;
    box-shadow: var(--shadow-md);
    transform: translateX(-100%);
    transition: transform var(--duration) var(--ease);
  }

  .admin-nav {
    flex-direction: column;
    flex-wrap: nowrap;
  }

  .nav-section {
    width: 100%;
  }

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

  .admin-sidebar-overlay {
    position: fixed;
    inset: 56px 0 0 0;
    z-index: 70;
    border: 0;
    background: rgba(15, 15, 15, 0.28);
    display: none;
    padding: 0;
    cursor: pointer;
  }

  body.admin-sidebar-open .admin-sidebar-overlay {
    display: block;
  }

  .admin-content {
    padding: 20px 14px 60px;
  }

  .hero,
  .card,
  .panel,
  .table-card,
  .metric,
  .label-card,
  .slip-card {
    border-radius: 20px;
  }

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

  .jaconnect-link-top {
    grid-template-columns: 1fr;
  }

  .jaconnect-inline-form {
    grid-template-columns: minmax(150px, 1fr);
  }

  .slip-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
