:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --surface-tint: #edf4f0;
  --line: #d9e1dd;
  --line-strong: #bccbc4;
  --text: #16211d;
  --muted: #5f7069;
  --quiet: #899892;
  --primary: #28745f;
  --primary-strong: #1d5c4b;
  --primary-soft: #e5f3ee;
  --accent: #345f9b;
  --accent-soft: #eaf0fb;
  --green: #2f7b54;
  --green-soft: #e6f4ed;
  --amber: #9a6316;
  --amber-soft: #fff3db;
  --red: #b3453d;
  --red-soft: #fae9e7;
  --violet: #6b5688;
  --violet-soft: #f0ebf7;
  --shadow: 0 14px 34px rgba(26, 45, 37, 0.08);
  --shadow-soft: 0 8px 22px rgba(26, 45, 37, 0.06);
  --radius: 8px;
  font-family:
    Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, #fbfcfb 0, var(--bg) 360px),
    var(--bg);
}

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

button {
  border: 0;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(40, 116, 95, 0.22);
  outline-offset: 2px;
}

[data-action="reset-demo"] {
  display: none !important;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 18px;
  overflow: auto;
  background: rgba(255, 255, 255, 0.92);
  border-right: 1px solid var(--line);
}

.brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 4px 4px 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-title {
  margin: 0;
  font-size: 17px;
  font-weight: 780;
  letter-spacing: 0;
}

.brand-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.nav-section {
  margin: 10px 8px 3px;
  color: var(--quiet);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-button {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 9px 10px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.nav-button:hover {
  background: var(--surface-soft);
}

.nav-button.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
  box-shadow: inset 3px 0 0 var(--primary);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: #eef2f0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1;
}

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

.nav-label,
.nav-hint {
  display: block;
  min-width: 0;
}

.nav-label {
  font-size: 14px;
  font-weight: 720;
}

.nav-hint {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.nav-count {
  min-width: 28px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

.nav-button.active .nav-count {
  background: #ffffff;
  color: var(--primary-strong);
}

.side-panel {
  display: grid;
  gap: 6px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.side-panel strong {
  color: var(--text);
}

.side-panel-label {
  margin: 0;
  color: var(--quiet);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 0 -28px 22px;
  padding: 22px 28px 16px;
  background: rgba(244, 246, 245, 0.9);
  border-bottom: 1px solid rgba(217, 225, 221, 0.78);
  backdrop-filter: blur(14px);
}

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

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

.page-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.16;
  letter-spacing: 0;
}

.topbar-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.topbar-metrics span {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 720;
}

.user-chip small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  max-width: 100%;
  padding: 9px 13px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover {
  border-color: var(--primary);
  background: var(--surface-soft);
}

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

.button.primary:hover {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
}

.button.ghost {
  background: transparent;
  border-color: transparent;
}

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

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-soft);
}

.workflow-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.workflow-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 76px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.workflow-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.workflow-card strong,
.workflow-card small {
  display: block;
}

.workflow-card strong {
  font-size: 15px;
}

.workflow-card small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.workflow-card em {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-tint);
  color: var(--primary-strong);
  font-size: 12px;
  font-style: normal;
  font-weight: 760;
}

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

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

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

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

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

.stat {
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.stat.accent {
  border-color: #c9d7ee;
  background: var(--accent-soft);
}

.stat.success {
  border-color: #c6dfd2;
  background: var(--green-soft);
}

.stat.warning {
  border-color: #efd4a1;
  background: var(--amber-soft);
}

.stat.danger {
  border-color: #edb9b3;
  background: var(--red-soft);
}

.stat-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.stat-value {
  margin: 0;
  font-size: 29px;
  font-weight: 780;
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.stat-note {
  margin: 10px 0 0;
  color: var(--quiet);
  font-size: 12px;
}

.section {
  margin-bottom: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: 0;
}

.panel-body {
  padding: 17px;
}

.split {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(0, 1.42fr);
  gap: 16px;
  align-items: start;
}

.split > .panel {
  position: sticky;
  top: 118px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar.compact {
  gap: 6px;
  margin-bottom: 0;
}

.toolbar .input {
  flex: 1 1 240px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

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

.input::placeholder,
.textarea::placeholder {
  color: #9aa7a1;
}

.textarea {
  min-height: 190px;
  resize: vertical;
  line-height: 1.45;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(40, 116, 95, 0.12);
}

.table-input {
  min-width: 150px;
}

.table-input.unit-input {
  min-width: 76px;
}

.table-input.price-input {
  min-width: 110px;
}

.table-input.alias-input {
  min-width: 320px;
}

.table-select {
  min-width: 240px;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 170px 180px;
  gap: 10px;
  margin-bottom: 14px;
}

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

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f7f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

td {
  font-size: 14px;
}

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

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover,
tbody tr:hover {
  background: var(--surface-soft);
}

tr.selected {
  background: var(--primary-soft);
}

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

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

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f0;
  color: #31443d;
  font-size: 12px;
  font-weight: 680;
  line-height: 1.25;
  white-space: nowrap;
}

.chip.blue {
  background: var(--accent-soft);
  color: var(--accent);
}

.chip.green {
  background: var(--green-soft);
  color: var(--green);
}

.chip.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.chip.red {
  background: var(--red-soft);
  color: var(--red);
}

.chip.violet {
  background: var(--violet-soft);
  color: var(--violet);
}

.request-list {
  max-height: calc(100vh - 276px);
  overflow: auto;
}

.request-row {
  display: grid;
  gap: 8px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.request-row:last-child {
  border-bottom: 0;
}

.request-row:hover {
  background: var(--surface-soft);
}

.request-row.active {
  background: var(--primary-soft);
  box-shadow: inset 3px 0 0 var(--primary);
}

.request-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.request-id {
  font-weight: 780;
}

.request-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 10px;
  color: var(--muted);
  font-size: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.fact {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.fact-label {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.fact-value {
  margin: 0;
  font-weight: 730;
  overflow-wrap: anywhere;
}

.raw-text {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  padding: 14px;
  border-radius: var(--radius);
  background: #18231f;
  color: #edf7f2;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 13px;
}

.line-name {
  display: grid;
  gap: 5px;
}

.raw-line {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.empty {
  padding: 30px 18px;
  color: var(--muted);
  text-align: center;
}

.notice {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  line-height: 1.4;
}

.notice strong {
  color: var(--text);
}

.notice.warning {
  border-color: #f1cf95;
  background: var(--amber-soft);
  color: #734a10;
}

.notice.danger {
  border-color: #efb1aa;
  background: var(--red-soft);
  color: #84312a;
}

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

.section-head h4 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0;
}

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

.waybill-textarea {
  min-height: 132px;
}

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

.timeline li {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.timeline time {
  color: var(--muted);
  font-size: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 31, 27, 0.48);
}

.modal {
  width: min(980px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: 0 30px 90px rgba(14, 24, 20, 0.3);
}

.poa-seal-settings {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.poa-seal-preview-box {
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.poa-seal-preview {
  display: block;
  width: 132px;
  height: 132px;
  object-fit: contain;
}

.poa-document {
  padding: 28px 34px 38px;
  color: #000000;
  background: #ffffff;
  font-family: Arial, sans-serif;
  font-size: 13px;
  line-height: 1.35;
}

.poa-title {
  margin: 16px 0 14px;
  text-align: center;
  font-size: 22px;
  line-height: 1.2;
}

.poa-valid,
.poa-bank,
.poa-lines div {
  margin: 2px 0;
}

.poa-under {
  padding: 2px 0;
  border-bottom: 1px solid #000000;
}

.poa-hint {
  margin: 0 0 4px;
  text-align: center;
  font-size: 11px;
}

.poa-lines {
  margin: 8px 0 18px;
}

.poa-list-title {
  margin: 18px 0 16px;
  text-align: center;
  font-weight: 800;
}

.poa-table {
  width: 100%;
  margin-top: 0;
  border-collapse: collapse;
}

.poa-table th,
.poa-table td {
  border: 1px solid #000000;
  padding: 3px 6px;
  color: #000000;
}

.poa-table th {
  position: static;
  background: #ffffff;
  text-align: center;
  font-weight: 800;
}

.poa-table th:first-child,
.poa-table td:first-child {
  width: 54px;
  text-align: center;
}

.poa-table th:nth-child(3),
.poa-table td:nth-child(3) {
  width: 110px;
  text-align: center;
}

.poa-table th:nth-child(4),
.poa-table td:nth-child(4) {
  width: 220px;
}

.poa-sign {
  display: grid;
  gap: 22px;
  margin-top: 28px;
  min-height: 182px;
  position: relative;
}

.poa-sign-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.8fr);
  gap: 24px;
}

.poa-seal {
  position: absolute;
  left: 220px;
  top: 26px;
  width: 190px;
  height: 190px;
  opacity: 1;
  object-fit: contain;
  pointer-events: none;
  z-index: 0;
}

.poa-sign > :not(.poa-seal) {
  position: relative;
  z-index: 1;
}

.poa-document th {
  position: static;
}

.confirm-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 22px;
}

.confirm-box {
  width: min(760px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.confirm-head {
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.confirm-body {
  padding: 22px;
}

.print-only {
  display: none;
}

@media (max-width: 1220px) {
  .workflow-strip,
  .stat-grid,
  .grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split,
  .grid.cols-3 {
    grid-template-columns: 1fr;
  }

  .split > .panel {
    position: static;
  }

  .request-list {
    max-height: none;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 15px;
  }

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

  .brand-mark {
    width: 40px;
    height: 40px;
  }

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

  .nav-section {
    grid-column: 1 / -1;
  }

  .nav-button {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .nav-count {
    grid-column: 2;
    justify-self: start;
  }

  .nav-hint {
    display: none;
  }

  .side-panel {
    display: none;
  }

  .main {
    padding: 0 14px 32px;
  }

  .topbar {
    position: static;
    display: grid;
    margin: 0 -14px 18px;
    padding: 18px 14px 14px;
  }

  .page-actions {
    justify-content: flex-start;
  }

  .workflow-strip,
  .stat-grid,
  .grid.cols-2,
  .grid.cols-4,
  .detail-grid,
  .filter-row {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 24px;
  }

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

  .button {
    white-space: normal;
  }

  .timeline li {
    grid-template-columns: 1fr;
  }

  .poa-row {
    display: grid;
  }

  .poa-sign-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .poa-seal {
    left: 50%;
    top: 46px;
    width: 154px;
    height: 154px;
    transform: translateX(-50%);
  }

  .poa-seal-settings {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  body.modal-open .app-shell {
    display: none;
  }

  .modal-backdrop {
    position: static;
    display: block;
    padding: 0;
    background: #ffffff;
  }

  .modal {
    width: 100%;
    max-height: none;
    border: 0;
    box-shadow: none;
  }

  .modal .panel-header,
  .no-print {
    display: none;
  }

  .poa-document {
    padding: 0;
  }
}
