:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --panel: #ffffff;
  --ink: #172019;
  --muted: #687267;
  --line: #dce2d8;
  --accent: #146c5f;
  --accent-strong: #0d4f47;
  --warn: #a14d16;
  --danger: #a83232;
  --shadow: 0 10px 30px rgba(33, 43, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.shell.locked > .app-header,
.shell.locked > main {
  display: none;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 18px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent);
  font-size: 24px;
  box-shadow: var(--shadow);
}

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

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 22px;
}

.balance-metric {
  grid-column: span 2;
}

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

.balance-form input {
  min-height: 38px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.message {
  min-height: 24px;
  margin: 8px 0;
  color: var(--accent-strong);
  font-size: 14px;
}

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

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.form {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

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

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

label.wide {
  grid-column: span 2;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(20, 108, 95, 0.24);
  border-color: var(--accent);
}

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

.helper-text {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.primary,
.secondary,
.small-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
}

.primary {
  margin-top: 12px;
  background: var(--accent);
  color: #ffffff;
}

.secondary {
  background: #e9eee7;
  color: var(--ink);
}

.small-button {
  min-height: 36px;
  background: #edf4f2;
  color: var(--accent-strong);
}

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

.item {
  display: grid;
  grid-template-columns: 1.3fr repeat(5, minmax(86px, 1fr)) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.item.compact-row {
  grid-template-columns: 1.4fr repeat(3, minmax(90px, 1fr));
}

.item.batch-row {
  grid-template-columns: 1.4fr repeat(5, minmax(90px, 1fr)) auto;
}

.name {
  min-width: 0;
}

.name strong {
  display: block;
  overflow-wrap: anywhere;
}

.name span,
.cell span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.cell {
  min-width: 0;
  overflow-wrap: anywhere;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  background: #eef5e9;
  color: #38620f;
  font-size: 13px;
}

.status.pending {
  background: #fff3df;
  color: var(--warn);
}

.empty {
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.login-screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(247, 248, 245, 0.96);
  z-index: 10;
}

.login-screen.active {
  display: flex;
}

.login-box {
  width: min(380px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-box h2 {
  margin-bottom: 18px;
  font-size: 24px;
}

.login-error {
  min-height: 22px;
  color: var(--danger);
  font-size: 14px;
}

@media (max-width: 820px) {
  .shell {
    padding: 14px;
  }

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

  .balance-metric {
    grid-column: 1 / -1;
  }

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

  .item,
  .item.batch-row,
  .item.compact-row {
    grid-template-columns: 1fr 1fr;
  }

  .name {
    grid-column: 1 / -1;
  }

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

@media (max-width: 520px) {
  .shell {
    padding: 12px;
  }

  h1 {
    font-size: 26px;
  }

  .tabs {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 8px 0;
    background: var(--bg);
  }

  .metric {
    min-height: 78px;
    padding: 12px;
  }

  .metric strong {
    font-size: 18px;
  }

  .form-grid,
  .item,
  .item.batch-row,
  .item.compact-row {
    grid-template-columns: 1fr;
  }

  .tabs {
    grid-template-columns: repeat(5, minmax(58px, 1fr));
    overflow-x: auto;
  }

  label.wide {
    grid-column: auto;
  }

  .primary,
  .secondary {
    width: 100%;
  }
}
