:root {
  --bg: #050914;
  --panel: rgba(12, 20, 38, 0.78);
  --panel-strong: rgba(14, 25, 48, 0.92);
  --panel-soft: rgba(21, 35, 62, 0.72);
  --line: rgba(180, 203, 238, 0.16);
  --line-strong: rgba(219, 181, 105, 0.42);
  --text: #edf4ff;
  --muted: #91a6c7;
  --gold: #dbb569;
  --gold-2: #f0d394;
  --cyan: #29c7bd;
  --blue: #5c9ded;
  --warning: #e3ad4f;
  --danger: #e85c66;
  --ok: #35c779;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

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

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: url("./client/assets/workspace-bg.png") center / cover no-repeat;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(3, 7, 18, 0.42);
}

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

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(4, 9, 22, 0.84);
  backdrop-filter: blur(16px);
}

.brand-block {
  padding: 28px 22px 22px;
  border-bottom: 1px solid var(--line);
}

.brand-name {
  color: var(--gold-2);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}

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

.nav-list {
  display: grid;
  gap: 8px;
  padding: 18px 14px;
}

.nav-item {
  height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: #161b25;
  border-color: var(--gold);
  background: var(--gold);
  font-weight: 800;
}

.sidebar-footer {
  display: grid;
  gap: 6px;
  margin-top: auto;
  padding: 18px 22px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.sidebar-footer strong {
  color: var(--text);
  font-size: 14px;
}

.main-shell {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 88px;
  padding: 20px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 10, 24, 0.66);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  font-size: 24px;
  line-height: 1.25;
}

.topbar p,
.panel-head p,
.kpi-card small {
  color: var(--muted);
  font-size: 13px;
}

.top-actions,
.form-actions,
.filter-row,
.row-actions,
.order-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.content {
  display: grid;
  gap: 18px;
  width: min(1500px, 100%);
  padding: 22px 26px 34px;
}

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

.kpi-card,
.panel,
.toast {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.kpi-card {
  min-height: 116px;
  border-radius: 8px;
  padding: 18px;
}

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

.kpi-card strong {
  display: block;
  margin: 9px 0 4px;
  color: var(--gold-2);
  font-size: 34px;
  line-height: 1;
}

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

.page {
  display: none;
}

.page.active {
  display: block;
}

.dashboard-grid,
.dispatch-grid,
.accounts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(360px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.wide-panel {
  grid-column: span 1;
}

.panel {
  min-width: 0;
  border-radius: 8px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 76px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 14, 30, 0.36);
}

.panel-head h2 {
  font-size: 18px;
  line-height: 1.25;
}

.primary-button,
.ghost-button,
.mini-button,
.danger-button {
  min-height: 36px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0 13px;
  color: var(--text);
  white-space: nowrap;
}

.primary-button {
  color: #101620;
  border-color: var(--gold);
  background: var(--gold);
  font-weight: 800;
}

.ghost-button,
.mini-button {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.danger-button {
  border-color: rgba(232, 92, 102, 0.7);
  background: rgba(232, 92, 102, 0.16);
  color: #ffd5d8;
}

.mini-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.primary-button:active,
.ghost-button:active,
.mini-button:active,
.danger-button:active,
.nav-item:active {
  transform: translateY(1px);
}

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td {
  color: #eaf2ff;
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(7, 14, 28, 0.88);
  color: var(--text);
  padding: 8px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
}

.dispatch-form,
.account-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 20px 20px;
}

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

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

.form-actions {
  justify-content: flex-end;
  grid-column: 1 / -1;
}

.selectable-list,
.alert-list,
.order-list {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.select-card,
.alert-card,
.order-card,
.preview-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 14, 28, 0.58);
  padding: 14px;
}

.select-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

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

.select-card.disabled {
  opacity: 0.52;
}

.preview-box {
  margin: 0 16px 16px;
}

.preview-box h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

pre {
  min-height: 180px;
  margin: 0;
  white-space: pre-wrap;
  color: #dbe7fb;
  font-family: "Microsoft YaHei UI", Consolas, monospace;
  line-height: 1.75;
}

.person-cell {
  display: grid;
  gap: 5px;
}

.person-name {
  font-weight: 800;
}

.person-meta,
.order-meta,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.status-pill,
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tag {
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.status-ready {
  color: #071b19;
  background: var(--cyan);
}

.status-away,
.status-pending,
.status-settling,
.status-created {
  color: #211604;
  background: var(--warning);
}

.status-serving {
  color: #061426;
  background: var(--blue);
}

.status-done {
  color: #06170e;
  background: var(--ok);
}

.status-offline,
.status-exception {
  color: #fff;
  background: var(--danger);
}

.order-card {
  display: grid;
  gap: 12px;
}

.order-card-head,
.alert-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.order-title,
.alert-title {
  font-weight: 800;
}

.order-meta {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.order-text {
  color: #dce8fb;
  font-size: 13px;
  line-height: 1.7;
}

.order-list.dense {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.alert-card {
  border-left: 4px solid var(--warning);
}

.alert-card.danger {
  border-left-color: var(--danger);
}

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

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 360px;
  min-height: 42px;
  border-radius: 8px;
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

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

@media (max-width: 1280px) {
  html,
  body {
    min-width: 980px;
  }

  .app-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .dashboard-grid,
  .dispatch-grid,
  .accounts-grid,
  .order-list.dense {
    grid-template-columns: 1fr;
  }
}
