:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #697386;
  --line: #dfe5ef;
  --accent: #1f7a6d;
  --accent-strong: #145a51;
  --warn: #a85d13;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(31, 42, 68, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  -webkit-text-size-adjust: 100%;
}

body.auth-pending .sidebar,
body.auth-pending .app {
  display: none;
}

body.auth-pending {
  overflow: hidden;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #f5f7fb 0%, #eef6f4 100%);
  overflow-y: auto;
}

.auth-screen.hidden {
  display: none;
}

.auth-card {
  width: min(430px, 100%);
  max-height: 100%;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.auth-card button {
  width: 100%;
  min-height: 44px;
}

.auth-card h1 {
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.auth-eyebrow {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 13px;
}

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

.auth-message {
  min-height: 20px;
  margin-top: 14px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 9px 13px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

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

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

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

.ghost {
  background: transparent;
}

.sidebar {
  width: 244px;
  padding: 24px 18px;
  background: #111827;
  color: #fff;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #2ba28f;
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.schedule-card small {
  color: #b8c2d2;
  margin-top: 3px;
}

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

.nav-item {
  text-align: left;
  color: #e8edf5;
  border-color: transparent;
  background: transparent;
}

.nav-item.active,
.nav-item:hover {
  background: #243145;
  border-color: #35465f;
}

.schedule-card {
  margin-top: 28px;
  border: 1px solid #34435b;
  border-radius: 8px;
  padding: 14px;
  background: #182235;
}

.schedule-card span,
.schedule-card strong,
.schedule-card small {
  display: block;
}

.schedule-card strong {
  margin: 8px 0 4px;
  font-size: 24px;
}

.app {
  flex: 1;
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

.topbar p,
.muted,
.note,
.sample {
  color: var(--muted);
}

.top-actions,
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.grid.two {
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
}

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

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

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #e9f6f3;
  color: var(--accent-strong);
  font-size: 13px;
  white-space: nowrap;
}

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

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

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

.note {
  margin-top: 14px;
  padding: 11px 12px;
  border-left: 3px solid var(--accent);
  background: #f0faf7;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

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

.kpis div {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcff;
}

.stats-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcff;
}

.kpis span,
.kpis strong,
.stats-grid span,
.stats-grid strong {
  display: block;
}

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

.kpis strong,
.stats-grid strong {
  margin-top: 5px;
  font-size: 24px;
}

.inline-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 160px;
}

.inline-upload {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

.inline-upload input {
  max-width: 360px;
}

.trend-chart {
  min-height: 250px;
  overflow-x: auto;
}

.trend-chart svg {
  display: block;
  min-width: 780px;
  width: 100%;
  height: 250px;
}

.chart-axis {
  stroke: #cbd5e1;
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.chart-dot {
  fill: #fff;
  stroke: var(--accent-strong);
  stroke-width: 2;
}

.trend-chart text {
  fill: var(--muted);
  font-size: 12px;
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

th {
  background: #f7f9fc;
  color: #465367;
  position: sticky;
  top: 0;
  z-index: 1;
}

td input,
td select {
  width: 105px;
  min-height: 32px;
  padding: 5px 7px;
}

td .wide {
  width: 170px;
}

.money,
.number {
  text-align: right;
}

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

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

.import-preview {
  display: grid;
  gap: 10px;
}

.import-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.sample {
  margin-top: 10px;
  font-size: 13px;
  font-family: Consolas, monospace;
}

@media (max-width: 980px) {
  body {
    display: block;
  }

  .sidebar {
    position: static;
    width: auto;
    min-height: 0;
    padding: 16px;
  }

  .app {
    padding: 18px;
  }

  .brand {
    margin-bottom: 14px;
  }

  .schedule-card {
    display: none;
  }

  .nav {
    display: flex;
    gap: 8px;
    margin: 0 -16px;
    overflow-x: auto;
    padding: 0 16px 3px;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    min-height: 40px;
    white-space: nowrap;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .button-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }

  .top-actions button,
  .button-row button {
    min-height: 42px;
  }

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

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

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

@media (max-width: 720px) {
  .auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(16px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom));
  }

  .auth-card {
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    padding: 22px 18px;
    border-radius: 8px;
  }

  .auth-card h1 {
    font-size: 22px;
    line-height: 1.25;
  }

  .auth-card .muted {
    margin-top: 8px;
    line-height: 1.6;
  }

  .auth-form {
    gap: 12px;
    margin-top: 20px;
  }

  .auth-card input,
  .auth-card button {
    min-height: 48px;
    font-size: 16px;
  }

  .auth-divider {
    margin: 16px 0;
  }

  h1 {
    font-size: 23px;
  }

  h2 {
    font-size: 17px;
  }

  .app {
    padding: 14px 12px 18px;
  }

  .panel {
    padding: 14px;
  }

  .table-wrap {
    margin: 0 -2px;
    border: 0;
    overflow: visible;
  }

  #employeeTable {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 12px;
    background: transparent;
  }

  #employeeTable thead {
    display: none;
  }

  #employeeTable,
  #employeeTable tbody,
  #employeeTable tr,
  #employeeTable td {
    display: block;
    width: 100%;
  }

  #employeeTable tr {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(31, 42, 68, 0.06);
  }

  #employeeTable td {
    display: grid;
    grid-template-columns: minmax(82px, 32%) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    border-bottom: 0;
    padding: 6px 0;
    white-space: normal;
  }

  #employeeTable td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 13px;
  }

  #employeeTable td:first-child {
    padding-top: 0;
  }

  #employeeTable td:last-child {
    padding-bottom: 0;
  }

  #employeeTable td input,
  #employeeTable td select,
  #employeeTable td .wide {
    width: 100%;
    min-height: 42px;
    font-size: 16px;
  }
}

@media (max-width: 420px) {
  .auth-screen {
    padding-left: 10px;
    padding-right: 10px;
  }

  .auth-card {
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    padding: 20px 15px;
  }

  .auth-card h1 {
    font-size: 20px;
  }

  .top-actions,
  .button-row {
    grid-template-columns: 1fr;
  }

  #employeeTable td {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}
