:root {
  --bg: #eef2f0;
  --panel: #ffffff;
  --line: #d9e2dd;
  --text: #18211d;
  --muted: #667571;
  --green: #0f6a4d;
  --green-dark: #074531;
  --red: #b42318;
  --amber: #986400;
  --soft: #f7faf8;
  --shadow: 0 12px 32px rgba(18, 38, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

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

button {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button.ghost {
  background: var(--soft);
  color: var(--green);
  border: 1px solid #aac8bb;
}

button.danger {
  background: var(--red);
}

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

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

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(15, 106, 77, 0.45);
  box-shadow: 0 0 0 3px rgba(15, 106, 77, 0.08);
}

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

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

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

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

.login-mark {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 16px;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-size: 26px;
  font-weight: 900;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #fcfefc 0%, #f7fbf8 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-weight: 900;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 7px;
  background: var(--green);
  color: #fff;
}

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

.nav button {
  justify-content: flex-start;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  box-shadow: none;
  border-radius: 8px;
}

.nav button.active {
  background: #e9f3ee;
  color: var(--green-dark);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(28, 44, 35, 0.04);
}

.title {
  font-size: 24px;
  font-weight: 900;
}

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

.panel {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  box-shadow: 0 8px 24px rgba(28, 44, 35, 0.04);
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  box-shadow: 0 8px 24px rgba(28, 44, 35, 0.04);
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

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

.grid-form .full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

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

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  background: #f1f6f3;
  color: #43544d;
  font-size: 12px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  line-height: 1.45;
}

.status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef3f1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status.approved,
.status.paid,
.status.confirmed,
.status.received {
  background: #dff3e7;
  color: var(--green-dark);
}

.status.rejected,
.status.disputed {
  background: #fde2df;
  color: var(--red);
}

.status.pending,
.status.pending_pay,
.status.unsubmitted,
.status.revised {
  background: #fff2c2;
  color: var(--amber);
}

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

.actions button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.thumb {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  border: 1px solid var(--line);
  background: #f4f7f5;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.notice {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #fff2c2;
  color: #735300;
}

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

.json-editor {
  min-height: 420px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(23, 33, 28, 0.92);
  color: #fff;
  font-weight: 700;
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

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

  .grid-form .wide,
  .grid-form .full {
    grid-column: auto;
  }

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