:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --line: #dce3ec;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #750f5a;
  --accent-strong: #5f0b48;
  --soft-green: #e8f7f1;
  --soft-blue: #eaf4ff;
  --soft-yellow: #fff7d6;
  --soft-orange: #fff0df;
  --warn: #b45309;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #e6f4f1, #f8fafc 55%, #eef2ff);
}

.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
}

.login-card h1 {
  color: var(--text);
}

.login-hint {
  color: var(--muted);
  margin-bottom: 2px;
}

.demo-users {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.demo-users button,
.ghost-btn {
  background: #e2e8f0;
  color: #334155;
}

.demo-users button:hover,
.ghost-btn:hover {
  background: #cbd5e1;
}

button, input, select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 9px 14px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px;
  background: #36113b;
  color: #fff;
}

.eyebrow {
  margin: 0 0 4px;
  color: #9de1d7;
  font-size: 13px;
}

h1, h2, h3, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

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

.status {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  padding: 7px 10px;
  font-size: 13px;
}

dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
}

dialog.approval-flow-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
}

dialog.operation-dialog {
  width: min(820px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.approval-flow-dialog-form {
  display: grid;
  gap: 14px;
  padding: 24px;
}

.approval-flow-dialog-heading,
.dialog-heading {
  display: grid;
  gap: 6px;
}

.approval-flow-dialog-heading h2,
.approval-flow-dialog-heading p,
.dialog-heading h2,
.dialog-heading p {
  margin-bottom: 0;
}

.approval-flow-dialog-heading p,
.dialog-heading p {
  color: var(--muted);
}

.password-dialog-form {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.password-dialog-form h2 {
  margin-bottom: 6px;
}

.password-dialog-form p {
  margin-bottom: 0;
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.app-shell {
  min-height: 100vh;
}

.app-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 184px minmax(0, 1fr);
  gap: 18px;
}

.side-nav {
  position: sticky;
  top: 18px;
  align-self: start;
  display: grid;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.side-nav .tab {
  width: 100%;
  justify-content: flex-start;
  border-radius: 8px;
  padding: 11px 12px;
  color: #334155;
  position: relative;
}

.side-nav .tab.active {
  background: #d9f4ea;
  color: #0f5f58;
}

.side-subnav {
  display: none;
  gap: 6px;
  margin: -4px 0 4px 12px;
  padding-left: 10px;
  border-left: 2px solid #dbeafe;
}

.side-subnav.expanded {
  display: grid;
}

.side-nav .tab.expanded {
  background: #f7e8f3;
  color: var(--accent);
}

.side-subtab {
  justify-content: flex-start;
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  color: #64748b;
  font-size: 14px;
}

.side-subtab.active,
.side-subtab:hover {
  background: #eef7ff;
  color: #0f5f58;
}

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

.stats-grid article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.stats-grid article.pastel-green { background: var(--soft-green); }
.stats-grid article.pastel-blue { background: var(--soft-blue); }
.stats-grid article.pastel-yellow { background: var(--soft-yellow); }
.stats-grid article.pastel-orange { background: var(--soft-orange); }

.stats-grid article.stat-card-action {
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.stats-grid article.stat-card-action:hover,
.stats-grid article.stat-card-action:focus-visible {
  border-color: rgba(13, 148, 136, .45);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .08);
  outline: none;
  transform: translateY(-1px);
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stats-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.workbench-section {
  padding: 16px 0 18px;
  border-bottom: 1px solid var(--line);
}

.workbench-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.workbench-section .section-heading-row {
  margin-bottom: 12px;
}

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

.workbench-actions button {
  justify-content: flex-start;
  min-height: 72px;
  padding: 18px;
  background: #fff7d6;
  color: #334155;
  border: 1px solid #fde68a;
  font-size: 18px;
}

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

.compact-activity-list .activity {
  padding: 12px 14px;
}

.workspace {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.workspace > .tabs {
  display: none;
}

.workbench-hero {
  background: linear-gradient(135deg, #e8f7f1, #fff7d6);
  border-radius: 8px;
  margin-bottom: 16px;
}

.module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.module-tabs button {
  background: #e2e8f0;
  color: #334155;
}

.module-tabs button.active {
  background: #d9f4ea;
  color: #0f5f58;
}

.secondary-menu {
  border-bottom: 1px solid var(--line);
  gap: 0;
  margin-bottom: 18px;
}

.secondary-menu button {
  border-radius: 8px 8px 0 0;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: 0;
  color: #475569;
}

.secondary-menu button.active {
  background: var(--surface);
  border-color: var(--line);
  color: var(--accent-strong);
}

.module-picker {
  margin-bottom: 16px;
}

.picker-btn {
  display: inline-grid;
  justify-items: start;
  gap: 4px;
  min-width: 220px;
  background: #eef7ff;
  border: 1px solid #bfdbfe;
  color: #1e3a5f;
}

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

.picker-btn strong {
  font-size: 16px;
}

.choice-dialog {
  display: grid;
  gap: 12px;
  padding: 24px;
}

.choice-dialog > button:not(.ghost-btn) {
  justify-content: flex-start;
  background: #f8fafc;
  border: 1px solid var(--line);
  color: #1f2937;
  padding: 14px 16px;
}

.choice-dialog > button:not(.ghost-btn):hover {
  background: #d9f4ea;
  color: var(--accent-strong);
}

.asset-tab-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.asset-tab-row .module-tabs {
  margin-bottom: 0;
}

.asset-secondary-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.text-link-btn {
  background: #f1f5f9;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  padding: 8px 10px;
}

.text-link-btn:hover,
.text-link-btn.active {
  background: #f7e8f3;
  border-color: #e9b7dc;
  color: var(--accent);
}

.info-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 10px 0 16px;
  color: var(--text);
  background: #f8fafc;
  font-size: 13px;
  line-height: 1.55;
}

.info-box p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.info-box.warning {
  border-color: #f6d58d;
  background: #fffbeb;
}

.quick-actions,
.asset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.summary-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  padding: 8px 12px;
  color: #475569;
}

.summary-pill strong {
  color: var(--accent);
}

.asset-row-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.asset-row-actions select,
.asset-row-actions input {
  width: auto;
  min-width: 110px;
}

.tab {
  background: transparent;
  color: var(--muted);
}

.side-nav .tab {
  background: transparent;
  color: #334155;
}

.side-nav .tab:hover {
  background: #f1f5f9;
}

.side-nav .tab.active {
  background: #d9f4ea;
  color: #0f5f58;
}

.tab-with-alert {
  position: relative;
}

.tab-alert {
  position: absolute;
  top: 7px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  line-height: 1;
}

.tab.active {
  background: #dff6f1;
  color: var(--accent-strong);
}

.panel {
  display: none;
  padding: 22px;
}

.panel.active {
  display: block;
}

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

.panel-heading p {
  color: var(--muted);
  margin-bottom: 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

input, select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff;
  color: var(--text);
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  font: 13px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  resize: vertical;
}

.item-search {
  border-color: #9ccfc8;
  background: #f0fdfa;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1180px;
}

.location-table table {
  min-width: 0;
}

.location-table th:last-child,
.location-table td:last-child {
  width: 190px;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  background: #e2e8f0;
  color: #334155;
}

.badge.warn {
  background: #fef3c7;
  color: var(--warn);
}

.badge.ok {
  background: #dcfce7;
  color: #166534;
}

.flow-mode-badge {
  border: 1px solid transparent;
  font-weight: 700;
}

.flow-mode-badge.new {
  border-color: #ef4444;
  background: #fee2e2;
  color: #991b1b;
}

.flow-mode-badge.editing {
  border-color: #f0b429;
  background: #fff3cd;
  color: #7a4b00;
}

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

.operation-form-wrap {
  max-width: 760px;
}

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

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

.operation-dialog-form {
  padding: 24px;
}

.operation-form > button {
  grid-column: 1 / -1;
}

.return-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  background: #f8fafc;
}

.form-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.transfer-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px 12px;
  align-items: end;
}

.transfer-form label:nth-of-type(3) {
  grid-column: span 2;
}

.transfer-form .item-search {
  min-width: 0;
  width: 100%;
}

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

.catalog-table table {
  min-width: 1320px;
}

#catalogRows input,
#catalogRows select {
  min-width: 120px;
}

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

.activity {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.activity.pending {
  border-color: #facc15;
  background: #fffbeb;
}

.activity.rejected {
  border-color: #fecaca;
  background: #fef2f2;
}

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

.location-actions {
  flex-wrap: nowrap;
  justify-content: flex-start;
}

.location-actions button {
  white-space: nowrap;
}

.location-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

.danger-btn:hover {
  background: #991b1b;
}

.section-subtitle {
  margin-top: 24px;
}

.embedded-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.section-description {
  color: var(--muted);
  margin-bottom: 14px;
}

.user-assignment-form {
  margin-bottom: 16px;
}

.kindergarten-form {
  grid-template-columns: minmax(220px, 1fr) auto;
  max-width: 520px;
}

#kindergartenRows input {
  min-width: 180px;
}

#userAssignmentRows input,
#userAssignmentRows select {
  min-width: 150px;
}

.settings-table {
  margin-bottom: 14px;
}

.settings-table table {
  min-width: 980px;
}

.settings-table th,
.settings-table td {
  text-align: center;
}

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

.settings-account-section h3 {
  margin-bottom: 0;
}

.settings-table th:first-child,
.settings-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: #fff;
}

.settings-flow-form {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin-bottom: 16px;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading-row h3 {
  margin-bottom: 0;
}

.section-title-with-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.flow-node-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-weight: 700;
}

.flow-node-heading button {
  width: auto;
}

.approval-steps {
  display: grid;
  gap: 10px;
}

.approval-step {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, 2fr) auto;
  gap: 12px;
  align-items: end;
}

.approval-role-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  min-height: 42px;
  align-items: center;
}

.approval-role-options label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  margin: 0;
  font-size: 13px;
  color: var(--text);
}

.fixed-flow-participants {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 6px;
}

.fixed-flow-node,
.configurable-flow-node {
  min-width: 190px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
}

.fixed-flow-node {
  background: #f1f5f9;
  color: #475569;
}

.configurable-flow-node {
  background: #ecfdf5;
  border-color: #99d8ca;
}

.fixed-flow-node span,
.configurable-flow-node span,
.fixed-flow-node small,
.configurable-flow-node small {
  color: var(--muted);
  font-size: 12px;
}

.flow-direction {
  align-self: center;
  color: var(--muted);
  font-weight: 700;
}

.approval-role-options input {
  min-height: auto;
}

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

.checkbox-line input {
  min-height: auto;
}

.activity p {
  margin-bottom: 4px;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #0f172a;
  opacity: 0;
  transform: translateY(12px);
  transition: 160ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .app-header, .panel-heading {
    flex-direction: column;
  }

  .stats-grid, .form-grid, .inline-form, .operation-form {
    grid-template-columns: 1fr;
  }

  .operation-form > button {
    grid-column: auto;
  }

  .approval-step {
    grid-template-columns: 1fr;
  }
}
