:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --line: #dce1e7;
  --line-strong: #b8c3d1;
  --text: #17202a;
  --muted: #687385;
  --brand: #0f766e;
  --brand-strong: #0b5d56;
  --brand-soft: #e3f4ef;
  --blue: #2563eb;
  --blue-soft: #e7f0fb;
  --red: #dc2626;
  --red-soft: #fdebea;
  --amber: #d97706;
  --amber-soft: #fff4d8;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.05), transparent 240px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 480px) 1fr;
  background:
    linear-gradient(90deg, rgba(244, 246, 248, 0.98), rgba(244, 246, 248, 0.7)),
    url("https://images.unsplash.com/photo-1551434678-e076c223a692?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.login-panel {
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid var(--line);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--brand);
  font-weight: 800;
}

.brand-title {
  font-size: 21px;
  font-weight: 800;
}

.brand-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.login-title {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.login-copy {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field span,
.form-label {
  color: #405064;
  font-size: 13px;
  font-weight: 700;
}

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

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(17, 102, 79, 0.12);
}

.btn {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #fff;
  color: var(--text);
  white-space: nowrap;
}

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

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

.btn.secondary {
  border-color: var(--line);
  background: #fff;
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

.btn.danger {
  border-color: #e9b8b4;
  background: var(--red-soft);
  color: var(--red);
}

.btn.compact {
  min-height: 30px;
  padding: 0 9px;
  font-size: 13px;
}

.login-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.login-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.login-side {
  display: flex;
  align-items: end;
  justify-content: end;
  padding: 44px;
}

.status-board {
  width: min(520px, 100%);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.status-board h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

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

.status-item {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 13px;
}

.status-item b {
  display: block;
  font-size: 20px;
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 272px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  color: var(--text);
  background: rgba(255, 255, 255, 0.94);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(12px);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar .brand-logo {
  background: linear-gradient(135deg, var(--brand), var(--blue));
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.22);
}

.sidebar .brand-sub {
  color: var(--muted);
}

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

.nav button {
  min-height: 39px;
  border: 0;
  border-radius: 8px;
  text-align: left;
  padding: 9px 10px;
  color: #314051;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.nav button:hover,
.nav button.active {
  background: #e4f3f0;
  color: var(--brand);
  font-weight: 800;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 9px;
  color: #aebdcc;
  font-size: 12px;
}

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

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -22px -24px 18px;
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 249, 0.9);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.page-title {
  display: grid;
  gap: 3px;
}

.page-title h1 {
  margin: 0;
  font-size: 22px;
}

.page-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.employee-filter-bar {
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 260px;
}

.employee-filter-bar .pill {
  flex: 0 0 auto;
}

.employee-filter-select {
  width: auto;
  min-width: 168px;
  max-width: 220px;
}

.date-input {
  width: 160px;
}

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

.flat-section {
  box-shadow: none;
}

.section-head {
  min-height: 52px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 16px;
}

.section-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.section-body {
  padding: 16px;
}

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

.kpi {
  position: relative;
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel-soft);
  overflow: hidden;
}

.kpi::after {
  content: "";
  position: absolute;
  right: -24px;
  bottom: -26px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(15, 118, 110, 0.08);
}

.kpi span {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.kpi strong {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 12px;
  font-size: 26px;
}

.kpi.good strong {
  color: var(--brand);
}

.kpi.warn strong {
  color: var(--amber);
}

.kpi.bad strong {
  color: var(--red);
}

.kpi.blue strong {
  color: var(--blue);
}

.compact-kpis .kpi {
  min-height: 94px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(340px, 0.9fr) minmax(420px, 1.1fr);
  gap: 14px;
}

.dashboard-work-grid {
  grid-template-columns: minmax(520px, 3fr) minmax(320px, 2fr);
}

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

.form-grid.three {
  grid-template-columns: repeat(3, minmax(130px, 1fr));
}

.form-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.spacer {
  height: 14px;
}

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

.summary-cell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.summary-cell span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-cell strong {
  display: block;
  margin-top: 6px;
  font-size: 17px;
  line-height: 1.35;
}

.inventory-strip {
  margin-top: 12px;
}

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

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.order-filters {
  width: 100%;
  flex-wrap: nowrap;
}

.order-filters .date-pill {
  flex: 0 0 auto;
}

.order-filters select {
  flex: 0 0 132px;
  width: 132px;
}

.order-filters .search-input {
  flex: 1 1 360px;
  min-width: 260px;
  width: auto;
}

.search-input {
  width: min(320px, 100%);
}

.date-pill {
  min-height: 36px;
  border-radius: 8px;
  padding: 4px 8px;
  gap: 7px;
}

.date-pill input {
  width: 138px;
  height: 28px;
  padding: 4px 6px;
  border: 0;
  background: transparent;
  font-weight: 800;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  height: 46px;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0f4f8;
  color: #405064;
  font-weight: 800;
}

tbody tr:hover {
  background: #f9fbfd;
}

.drag-th {
  color: #8391a3;
  font-weight: 600;
}

.drag-th::after {
  content: " ||";
  color: #a1acb9;
  padding-left: 5px;
}

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

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.mini-action {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.mini-action:hover {
  border-color: #b7e3dc;
  background: #ecfdf9;
  color: var(--brand);
}

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

.dispatch-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.dispatch-card.compact {
  padding: 12px 14px;
}

.dispatch-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dispatch-card-title {
  font-weight: 800;
}

.dispatch-card-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.good-text {
  color: var(--brand) !important;
}

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

.icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex: 0 0 auto;
}

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

.flow-step {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
}

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

.flow-step strong {
  font-size: 24px;
  color: var(--brand);
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.pill.green {
  color: var(--brand);
  border-color: #b9ddce;
  background: var(--brand-soft);
}

.pill.blue {
  color: var(--blue);
  border-color: #b9cdeb;
  background: var(--blue-soft);
}

.pill.red {
  color: var(--red);
  border-color: #efc3c0;
  background: var(--red-soft);
}

.pill.amber {
  color: var(--amber);
  border-color: #f0d493;
  background: var(--amber-soft);
}

.inline-input {
  width: 110px;
  height: 30px;
}

.inline-actual-coin {
  width: 88px;
  height: 30px;
  border: 0;
  background: transparent;
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding: 0 4px 0 8px;
  box-shadow: none;
}

.inline-actual-coin:focus {
  border-color: transparent;
  box-shadow: none;
}

.coin-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 1px 6px 1px 1px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  white-space: nowrap;
}

.coin-input-wrap:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(17, 102, 79, 0.12);
}

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

.mini-input {
  width: 90px;
  height: 30px;
}

.ledger-form {
  grid-template-columns: minmax(120px, 0.8fr) minmax(150px, 1fr) minmax(180px, 1.25fr) minmax(150px, 1.1fr) minmax(140px, 1fr) minmax(160px, 1.1fr) auto;
}

.ledger-form .mini-input {
  width: 100%;
  min-width: 132px;
  height: 38px;
}

.order-entry {
  grid-template-columns: 1.05fr 1.25fr 1fr 0.9fr 0.9fr 1.15fr auto;
}

.staff-load-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 10px;
}

.staff-card {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.staff-card b,
.staff-card span {
  display: block;
}

.staff-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.billing-plans {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.plan-option {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
  cursor: pointer;
  display: grid;
  gap: 5px;
}

.plan-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.plan-option b,
.plan-option span {
  display: block;
}

.plan-option span {
  color: var(--brand);
  font-size: 22px;
  font-weight: 800;
}

.plan-option.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(17, 102, 79, 0.1);
}

.billing-preview {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.billing-preview span,
.billing-preview em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.billing-preview strong {
  color: var(--brand);
  font-size: 24px;
}

.billing-form {
  margin-top: 6px;
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--panel-soft);
}

.callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid #b7e3dc;
  border-radius: 8px;
  background: #ecfdf9;
  color: #134e4a;
  font-size: 13px;
  line-height: 1.6;
}

.callout.warn {
  border-color: #fde68a;
  background: #fffbeb;
  color: #7c2d12;
}

.employee-table td:first-child strong {
  color: #17202a;
}

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

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

.metric-list {
  display: grid;
  gap: 9px;
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.metric-row span {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  background: #17202a;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 20;
  font-size: 14px;
}

.mobile-menu {
  display: none;
}

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

  .login-side {
    display: none;
  }

  .login-panel {
    min-height: 100vh;
    padding: 28px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px;
  }

  .sidebar .brand-mark,
  .sidebar-foot {
    display: none;
  }

  .nav {
    display: flex;
    overflow-x: auto;
  }

  .nav button {
    flex: 0 0 auto;
  }

  .main {
    padding: 14px;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
    height: auto;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .order-filters {
    flex-wrap: wrap;
  }

  .employee-filter-bar {
    justify-content: flex-start;
    min-width: 0;
  }

  .kpi-grid,
  .grid-2,
  .grid-3,
  .report-grid,
  .staff-load-grid,
  .billing-plans,
  .flow {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .form-grid.three,
  .ledger-form,
  .order-entry {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .employee-filter-select {
    width: 100%;
    max-width: none;
  }

  .order-filters select,
  .order-filters .search-input {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }

  .form-grid,
  .form-grid.three,
  .ledger-form,
  .order-entry,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .login-title {
    font-size: 24px;
  }

  .kpi strong {
    font-size: 20px;
  }
}
