:root {
  color-scheme: light;
  --bg: #f3f7fb;
  --surface: #ffffff;
  --surface-soft: #fbfdff;
  --line: #d7e0ea;
  --text: #1f2933;
  --muted: #687789;
  --brand: #0f766e;
  --brand-strong: #0b5f59;
  --accent: #d97706;
  --danger: #dc2626;
  --info: #2563eb;
  --sidebar: #17343a;
  --shadow: 0 14px 34px rgba(31, 41, 51, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

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

button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 0 12px;
  white-space: nowrap;
}

button:hover {
  border-color: #7fb7b1;
  background: var(--surface-soft);
}

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

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

button.warn {
  border-color: #f4c76b;
  background: #fff8e8;
  color: #8a5a00;
}

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

button.icon {
  width: 34px;
  padding: 0;
  text-align: center;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.icon-link:hover {
  border-color: #7fb7b1;
  background: var(--surface-soft);
}

.icon-link.danger {
  border-color: #fecaca;
  background: #fff7f7;
  color: var(--danger);
}

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 6px 9px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 118, 110, .18);
  border-color: var(--brand);
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef6f8;
  color: #234047;
  font-size: 12px;
  font-weight: 700;
}

tr:hover td {
  background: #f8fbff;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 28px;
}

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

.login-box h1 {
  margin: 0 0 18px;
  font-size: 22px;
  letter-spacing: 0;
}

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

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

.sidebar {
  background: var(--sidebar);
  color: #f7fbfb;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand {
  display: grid;
  gap: 3px;
  padding: 4px 4px 10px;
  border-bottom: 1px solid rgba(226, 242, 244, .18);
}

.brand strong {
  font-size: 17px;
  letter-spacing: 0;
}

.brand span,
.side-meta {
  color: rgba(235, 251, 252, .72);
  font-size: 12px;
}

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

.nav button {
  width: 100%;
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  color: rgba(241, 252, 253, .84);
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: var(--brand);
  color: #fff;
}

.side-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.side-footer button {
  border-color: rgba(226, 242, 244, .2);
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(8px);
}

.topbar h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.content {
  min-width: 0;
  padding: 16px;
  overflow: auto;
}

.view {
  display: none;
  gap: 14px;
}

.view.active {
  display: grid;
}

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

.panel-head {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.panel-head h3 {
  margin: 0;
  font-size: 15px;
}

.panel-body {
  padding: 12px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

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

.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));
}

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

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

.span-3 {
  grid-column: span 3;
}

.span-4 {
  grid-column: span 4;
}

.table-wrap {
  max-height: 460px;
  overflow: auto;
}

.table-wrap.small {
  max-height: 270px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 10px;
}

.stat {
  min-height: 86px;
  border: 1px solid var(--line);
  border-top: 3px solid #66c2b7;
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  display: grid;
  align-content: space-between;
}

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

.stat strong {
  font-size: 23px;
  letter-spacing: 0;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, .8fr);
  gap: 14px;
}

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

.hidden {
  display: none !important;
}

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

.right {
  text-align: right;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf2f7;
  color: #34495e;
  font-size: 12px;
}

.status.ok {
  background: #e6f6f3;
  color: var(--brand-strong);
}

.status.warn {
  background: #fff4e5;
  color: #8a5a00;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  min-width: 220px;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  background: #1f2933;
  color: #fff;
  padding: 11px 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .18s ease;
}

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

.toast.error {
  background: var(--danger);
}

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

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

.confirm-box {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
  display: grid;
  gap: 14px;
}

.confirm-box h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.confirm-box .actions {
  justify-content: flex-end;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
  }

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

  .split,
  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .grid.cols-6,
  .stats-row {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-3,
  .span-4 {
    grid-column: auto;
  }

  .topbar {
    align-items: flex-start;
    height: auto;
    padding: 12px;
    flex-direction: column;
  }
}
