:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-quiet: #eef4f4;
  --text: #1d2935;
  --muted: #667085;
  --line: #d7dee4;
  --line-strong: #aeb8c2;
  --primary: #006f78;
  --primary-dark: #005a62;
  --primary-soft: #dceff0;
  --accent: #a15c00;
  --accent-soft: #fff0d8;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --success: #067647;
  --success-soft: #dcfae6;
  --warning: #b54708;
  --warning-soft: #fef0c7;
  --purple: #6941c6;
  --purple-soft: #ebe9fe;
  --shadow: 0 12px 34px rgba(28, 39, 49, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Yu Gothic", "YuGothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui,
    sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

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

button,
.button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  text-decoration: none;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

button:hover,
.button:hover {
  background: #f9fbfb;
  border-color: #8794a1;
}

button:active,
.button:active {
  transform: translateY(1px);
}

button.primary,
.button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

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

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

button.subtle {
  background: transparent;
  border-color: transparent;
  color: var(--primary);
}

button.full {
  width: 100%;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

label {
  color: var(--text);
  display: grid;
  font-weight: 700;
  gap: 7px;
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  min-height: 42px;
  padding: 8px 10px;
  width: 100%;
}

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

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.button:focus-visible {
  outline: 3px solid rgba(0, 111, 120, 0.22);
  outline-offset: 2px;
}

table {
  border-collapse: collapse;
  width: 100%;
}

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

th {
  background: #f8fafb;
  color: #475467;
  font-size: 13px;
  white-space: nowrap;
}

td {
  background: var(--surface);
}

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

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 0 auto;
  max-width: 480px;
  padding: 28px;
  width: 100%;
}

.brand {
  align-items: center;
  display: flex;
  gap: 14px;
  margin-bottom: 24px;
}

.brand-mark {
  align-items: center;
  background: var(--primary);
  border-radius: 6px;
  color: #ffffff;
  display: grid;
  flex: 0 0 48px;
  font-size: 22px;
  font-weight: 800;
  height: 48px;
  justify-items: center;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
}

.brand p {
  color: var(--muted);
  font-size: 13px;
}

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

.login-presets {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.auth-switch {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
}

.auth-switch strong {
  font-size: 14px;
}

.auth-check {
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

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

.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px;
}

.side-brand {
  align-items: center;
  display: flex;
  gap: 10px;
  padding: 0 6px;
}

.side-brand .brand-mark {
  flex-basis: 38px;
  font-size: 18px;
  height: 38px;
}

.side-brand strong,
.side-brand span {
  display: block;
}

.side-brand strong {
  font-size: 15px;
}

.side-brand span {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  justify-content: flex-start;
  min-height: 42px;
  width: 100%;
}

.nav button.active {
  background: var(--primary-soft);
  border-color: #8cc7cc;
  color: var(--primary-dark);
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  min-height: 78px;
  padding: 18px 28px;
}

.topbar h1,
.topbar p {
  margin: 0;
}

.topbar h1 {
  font-size: 23px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.top-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.user-chip,
.notify-chip,
.role-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 10px;
}

.notify-chip {
  background: var(--accent-soft);
  border-color: #f3c178;
  color: #7a3b00;
}

.content {
  display: grid;
  gap: 18px;
  padding: 24px 28px 42px;
}

.dashboard-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

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

.stat strong {
  display: block;
  font-size: 28px;
  margin-top: 4px;
}

.section,
.panel,
.form-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.section {
  overflow: hidden;
}

.section-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 16px 18px;
}

.section-header h2,
.section-header p {
  margin: 0;
}

.section-header h2 {
  font-size: 18px;
}

.section-header p {
  color: var(--muted);
  font-size: 13px;
}

.section-body,
.panel {
  padding: 18px;
}

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

.side-stack {
  align-content: start;
  display: grid;
  gap: 18px;
}

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

.quick-link {
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 6px;
  min-height: 88px;
  padding: 15px;
  text-align: left;
}

.quick-link strong,
.quick-link span {
  display: block;
}

.quick-link span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.form-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.stack-form,
.master-form {
  display: grid;
  gap: 16px;
}

.stack-form {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

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

.form-grid .wide,
.wide {
  grid-column: 1 / -1;
}

.checklist {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding-top: 16px;
}

.checkline {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  font-weight: 700;
}

.checkline input {
  margin-top: 4px;
  min-height: auto;
  width: auto;
}

.form-actions,
.action-row,
.filter-row,
.tabs {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-row {
  align-items: end;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.filter-row label {
  flex: 1 1 190px;
}

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

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

.status-badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
  white-space: nowrap;
}

.status-waiting {
  background: var(--warning-soft);
  color: #7a3a00;
}

.status-accepted,
.status-checking {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.status-returned {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-submitted,
.status-received {
  background: var(--purple-soft);
  color: var(--purple);
}

.status-sent,
.status-complete {
  background: var(--success-soft);
  color: var(--success);
}

.detail-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
}

.detail-grid {
  display: grid;
  gap: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}

.detail-grid div {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 3px;
  padding: 12px 14px;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.timeline {
  display: grid;
  gap: 9px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline li {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 9px;
}

.timeline li::before {
  background: #d0d5dd;
  border-radius: 999px;
  content: "";
  flex: 0 0 10px;
  height: 10px;
  width: 10px;
}

.timeline li.done::before {
  background: var(--primary);
}

.timeline li.current {
  color: var(--text);
  font-weight: 800;
}

.history-list,
.notification-list,
.compact-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.history-list li,
.notification-list li,
.compact-list li {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 4px;
  list-style: none;
  padding: 11px 12px;
}

.history-list strong,
.notification-list strong,
.compact-list strong {
  display: block;
}

.history-list span,
.notification-list span,
.compact-list span {
  color: var(--muted);
  font-size: 13px;
}

.empty {
  color: var(--muted);
  margin: 0;
  padding: 12px 0;
}

.pdf-preview {
  border: 1px solid var(--line);
  border-radius: 6px;
  height: 420px;
  width: 100%;
}

.upload-target {
  align-items: center;
  background: #f8fafb;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  justify-items: center;
  min-height: 164px;
  padding: 22px;
  text-align: center;
}

.upload-target input {
  max-width: 420px;
}

.master-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, 0.48fr) minmax(0, 1fr);
}

.tabs button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.toast {
  background: #111827;
  border-radius: 8px;
  bottom: 18px;
  color: #ffffff;
  left: 50%;
  max-width: min(520px, calc(100vw - 28px));
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 14px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  z-index: 40;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

  .detail-layout,
  .master-grid {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    gap: 14px;
    padding: 14px;
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
  }

  .nav button {
    flex: 0 0 auto;
    width: auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .top-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .content {
    padding: 16px 14px 32px;
  }

  .quick-grid,
  .form-grid,
  .dashboard-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .login-presets {
    grid-template-columns: 1fr;
  }

  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 14px;
  }

  .login-page {
    padding: 16px;
  }

  .login-card {
    padding: 20px;
  }

  .brand h1 {
    font-size: 19px;
  }

  .form-actions button,
  .form-actions .button,
  .action-row button,
  .action-row .button,
  .filter-row button {
    width: 100%;
  }
}
