:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #687382;
  --line: #d8dee7;
  --blue: #145b9b;
  --green: #0f7a55;
  --yellow: #b7791f;
  --red: #b42318;
  --shadow: 0 18px 40px rgba(27, 39, 51, 0.09);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

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

.app-header h1,
.section-title h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  color: rgba(255, 255, 255, 0.78);
}

.identity-pill {
  max-width: 220px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 7px 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button.primary {
  border-color: #2d7cc1;
  background: #2d7cc1;
  color: #fff;
}

button.wide {
  width: 100%;
}

button.ghost {
  background: transparent;
}

.logout-button {
  border-color: rgba(255, 255, 255, 0.32);
  color: #fff;
}

button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 22px;
  width: min(1440px, calc(100% - 40px));
  margin: 24px auto 48px;
}

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

.control-panel {
  align-self: start;
  position: sticky;
  top: 20px;
  padding: 20px;
}

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

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

.control-panel .section-title {
  padding: 0 0 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding-top: 18px;
}

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

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
}

.toggle {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  color: var(--ink);
}

.toggle input {
  width: 18px;
  min-height: 18px;
}

.result-area {
  display: grid;
  gap: 18px;
}

.alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 128px;
  padding: 26px 30px;
  border-radius: 8px;
  background: #145b9b;
  color: #fff;
  box-shadow: var(--shadow);
}

.alert-banner h2 {
  margin: 0;
  font-size: 34px;
}

.alert-banner strong {
  font-size: 34px;
}

.alert-banner.is-green {
  background: var(--green);
}

.alert-banner.is-yellow {
  background: var(--yellow);
}

.alert-banner.is-red {
  background: var(--red);
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.metric-row article {
  min-height: 94px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.metric-row strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

td:nth-child(2) {
  width: 120px;
  text-align: center;
}

td:nth-child(3),
td:nth-child(4),
td:nth-child(5) {
  width: 100px;
  text-align: center;
}

.staff-input {
  width: 84px;
  min-height: 34px;
  text-align: center;
}

.status,
.gap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.status.match,
.gap.match {
  background: #e8f5ef;
  color: var(--green);
}

.status.short,
.gap.short {
  background: #fdecea;
  color: var(--red);
}

.status.surplus,
.gap.surplus {
  background: #fff5df;
  color: var(--yellow);
}

.row-short {
  background: #fff8f7;
}

.danger-text {
  color: var(--red);
}

.ok-text {
  color: var(--green);
}

.is-green {
  color: var(--green);
}

.is-yellow {
  color: var(--yellow);
}

.is-red {
  color: var(--red);
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: #102033;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 420px;
  width: min(1040px, calc(100% - 40px));
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.28);
}

.auth-hero {
  display: grid;
  align-content: center;
  gap: 18px;
  min-height: 560px;
  padding: 48px;
  background: linear-gradient(135deg, #103459, #176d6a);
  color: #fff;
}

.auth-hero h1,
.auth-card h2 {
  margin: 0;
}

.auth-hero p {
  max-width: 520px;
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.7;
}

.domain-card {
  display: grid;
  gap: 6px;
  width: fit-content;
  margin-top: 16px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  padding: 16px 18px;
}

.domain-card span {
  color: rgba(255, 255, 255, 0.62);
}

.auth-card {
  display: grid;
  align-content: center;
  gap: 20px;
  padding: 42px;
}

.auth-card p {
  min-height: 22px;
  margin: 8px 0 0;
  color: var(--muted);
}

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

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.divider::before,
.divider::after {
  height: 1px;
  background: var(--line);
  content: "";
}

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

.note-list,
.rule-book ul {
  margin: 0;
  padding: 16px 20px 20px 38px;
}

.note-list li,
.rule-book li {
  margin: 8px 0;
  line-height: 1.55;
}

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

.rule-book article {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.rule-book h3 {
  margin: 0;
  padding: 16px 20px 0;
  font-size: 17px;
}

@media (max-width: 980px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .control-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .layout {
    width: min(100% - 24px, 1440px);
  }

  .form-grid,
  .metric-row,
  .split,
  .rule-book,
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .alert-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-hero {
    min-height: 300px;
    padding: 32px;
  }
}
