:root {
  --bg: #edf7f8;
  --surface: #ffffff;
  --surface-soft: #f5fbfb;
  --surface-strong: #e2f3f1;
  --line: #c9dddf;
  --line-strong: #9dbbc0;
  --text: #193037;
  --muted: #647980;
  --accent: #087d8a;
  --accent-strong: #065f6c;
  --accent-soft: #d9f2f1;
  --coral: #d46a5d;
  --warn: #a86b12;
  --danger: #b84d4d;
  --shadow: 0 12px 32px rgba(15, 78, 91, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(8, 125, 138, 0.07), transparent 240px),
    repeating-linear-gradient(135deg, rgba(8, 125, 138, 0.035) 0 1px, transparent 1px 26px),
    var(--bg);
  color: var(--text);
  font-family: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic", sans-serif;
  letter-spacing: 0;
}

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

a:hover {
  color: var(--accent-strong);
}

.icon {
  width: 1.05em;
  height: 1.05em;
  flex: 0 0 auto;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}

.menu-toggle,
.mobile-header,
.sidebar-backdrop,
.sidebar-close {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  padding: 24px 18px;
  background:
    linear-gradient(180deg, #083d4a 0%, #0b5661 54%, #0b4755 100%);
  color: #f3fbfb;
}

.sidebar h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.13);
  color: #91f1ea;
}

.sidebar p,
.sidebar a {
  color: rgba(243, 251, 251, 0.78);
}

.sidebar p {
  margin: 0;
  line-height: 1.65;
  font-size: 0.9rem;
}

.nav {
  display: grid;
  gap: 6px;
  margin-top: 24px;
}

.nav a,
.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: rgba(243, 251, 251, 0.84);
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.nav a:hover,
.sidebar-footer a:hover {
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
  text-decoration: none;
}

.nav a.active {
  background: #e8fbf7;
  color: #073f49;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
}

.nav-icon {
  display: grid;
  place-items: center;
}

.sidebar-footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.sidebar-footer .legal-link {
  min-height: 34px;
  font-size: 0.82rem;
  opacity: 0.78;
}

.content {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar h2 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 800;
}

.topbar p {
  margin: 6px 0 0;
}

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

.cards {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr));
}

.card,
.panel {
  min-width: 0;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card {
  position: relative;
  overflow: hidden;
  padding: 16px;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #63c7c1, var(--coral));
}

.card .label {
  color: var(--muted);
  font-size: 0.86rem;
}

.card .value {
  margin-top: 8px;
  font-size: 1.28rem;
  line-height: 1.35;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.panel {
  padding: 18px;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 1.08rem;
}

.grid-2 {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

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

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

td {
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

form.inline {
  display: inline;
}

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

.select-all-control {
  display: inline-flex;
  align-items: center;
  grid-auto-flow: column;
  gap: 7px;
  min-height: 38px;
  width: auto;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.btn,
button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  padding: 9px 13px;
  font: inherit;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.btn:hover,
button:hover,
input[type="submit"]:hover {
  background: var(--accent-strong);
  color: #fff;
  text-decoration: none;
}

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

.btn.secondary:hover,
button.secondary:hover {
  background: var(--accent-soft);
  border-color: #8cccca;
  color: var(--accent-strong);
}

.btn.danger,
button.danger {
  background: var(--danger);
  color: #fff;
}

.btn.danger:hover,
button.danger:hover {
  background: #973d3d;
}

.icon-only {
  width: 38px;
  padding: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--surface-strong);
  color: var(--accent-strong);
}

.pill.warn {
  background: #fff3d7;
  color: var(--warn);
}

.pill.ok {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.pill.danger {
  background: #fae0dd;
  color: #8e3939;
}

.flash {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.flash.success {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: #9bd8d5;
}

.flash.error {
  background: #fae0dd;
  color: #8e3939;
  border-color: #efb4ad;
}

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

.form-grid.columns-2 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.field-block {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.field-label {
  color: var(--muted);
}

.field-help {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.6;
}

.field-note {
  display: grid;
  gap: 7px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font: inherit;
  outline: none;
}

input[type="checkbox"] {
  width: auto;
  min-height: auto;
  accent-color: var(--accent);
}

.checkbox-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-check {
  display: inline-flex;
  align-items: center;
  grid-auto-flow: column;
  gap: 7px;
  width: auto;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.chip-check:has(input:checked) {
  border-color: #8cccca;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.paper-select {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 125, 138, 0.14);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.bulk-rows {
  display: grid;
  gap: 10px;
}

.bulk-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.1fr) minmax(140px, 0.8fr) minmax(180px, 1.25fr) minmax(160px, 0.95fr) minmax(150px, 0.9fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.compact-list {
  display: grid;
  gap: 10px;
}

.compact-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.compact-item > div {
  min-width: 0;
}

.compact-item strong,
.compact-detail,
.paper-card h4,
.paper-url,
.paper-memo {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.compact-item .meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.compact-list.logs .compact-item {
  align-items: center;
}

.compact-detail {
  max-width: 58%;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: right;
}

.paper-card-list {
  display: none;
}

.paper-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(15, 78, 91, 0.07);
}

.paper-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.paper-title-block {
  min-width: 0;
}

.paper-title-block h4 {
  margin: 4px 0 0;
  font-size: 1rem;
  line-height: 1.45;
}

.paper-order,
.paper-date {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.paper-check {
  display: inline-flex;
  align-items: center;
  grid-auto-flow: column;
  gap: 6px;
  width: auto;
  padding: 7px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  white-space: nowrap;
}

.paper-url {
  display: block;
  font-size: 0.88rem;
}

.paper-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.paper-meta-grid div {
  min-width: 0;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.paper-meta-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.paper-meta-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
}

.paper-memo {
  margin: 0;
  padding: 10px;
  border-radius: var(--radius);
  background: #f9fcfc;
  color: var(--muted);
}

.paper-actions {
  padding-top: 4px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-card {
  width: min(100%, 440px);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.45rem;
}

.login-legal {
  margin: 16px 0 0;
  text-align: center;
  font-size: 0.82rem;
}

.public-shell {
  min-height: 100vh;
  padding: 28px;
}

.public-card {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 28px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.public-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 18px;
}

.terms-document {
  line-height: 1.85;
}

.terms-document header {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}

.terms-document .eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.terms-document h1 {
  margin: 0 0 14px;
  font-size: clamp(1.55rem, 4vw, 2.1rem);
}

.terms-document h2 {
  margin: 26px 0 10px;
  font-size: 1.05rem;
  color: var(--accent-strong);
}

.terms-document p,
.terms-document li {
  color: var(--text);
}

.terms-document ol {
  padding-left: 1.4rem;
}

.terms-document dl {
  display: grid;
  gap: 8px;
}

.terms-document dl div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.terms-document dt {
  color: var(--muted);
  font-weight: 700;
}

.terms-document dd {
  margin: 0;
}

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

@media (max-width: 900px) {
  .mobile-header {
    position: fixed;
    inset: 0 0 auto;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 62px;
    padding: 10px 14px;
    background: rgba(237, 247, 248, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
  }

  .menu-button,
  .sidebar-close {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--accent-strong);
    cursor: pointer;
  }

  .mobile-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    font-weight: 800;
  }

  .mobile-brand .brand-mark {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: #e8fbf7;
  }

  .layout {
    display: block;
    min-height: 100vh;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(82vw, 310px);
    min-height: 100vh;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: 18px 0 38px rgba(7, 52, 61, 0.24);
  }

  .sidebar-close {
    position: absolute;
    top: 14px;
    right: 14px;
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(7, 38, 45, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .menu-toggle:checked ~ .layout .sidebar {
    transform: translateX(0);
  }

  .menu-toggle:checked ~ .layout .sidebar-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

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

  .content {
    padding: 84px 18px 18px;
  }

  .topbar {
    flex-direction: column;
  }

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

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

  .compact-item {
    display: grid;
  }

  .compact-detail {
    max-width: none;
    text-align: left;
  }

  .paper-card-list {
    display: grid;
    gap: 12px;
  }

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

  .paper-meta-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 76px 12px 12px;
  }

  .sidebar {
    padding: 18px 12px;
  }

  .sidebar p {
    display: none;
  }

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

  .nav a,
  .sidebar-footer a {
    min-height: 44px;
    padding: 9px 10px;
    font-size: 0.9rem;
  }

  .panel,
  .card,
  .login-card,
  .public-card {
    padding: 14px;
  }

  .public-shell {
    padding: 12px;
  }

  .public-actions {
    justify-content: stretch;
  }

  .public-actions .btn {
    width: 100%;
  }

  .terms-document dl div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .cards,
  .grid-2,
  .form-grid.columns-2 {
    grid-template-columns: 1fr;
  }

  .topbar select {
    min-width: 100%;
  }

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

  .actions .select-all-control {
    width: 100%;
  }

  .actions form.inline {
    display: block;
    width: 100%;
  }

  .actions .btn,
  .actions button {
    width: 100%;
  }

  .actions .icon-only {
    width: 100%;
  }

  .table-wrap table {
    min-width: 700px;
  }
}
