:root {
  --bg: #0f1419;
  --bg2: #1a2332;
  --card: #243044;
  --card2: #2c3b52;
  --text: #f0f4f8;
  --muted: #9aafc3;
  --primary: #3b82f6;
  --primary2: #2563eb;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --pink: #ec4899;
  --radius: 16px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(165deg, #0b1220 0%, #152238 45%, #1a2740 100%);
  color: var(--text);
}

body {
  font-size: 16px;
  line-height: 1.45;
}

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

.hidden {
  display: none !important;
}

#app {
  min-height: 100vh;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: rgba(26, 35, 50, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.6rem;
}

.login-card .sub {
  color: var(--muted);
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0f1724;
  color: var(--text);
  border-radius: 12px;
  padding: 14px 14px;
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.15s transform, 0.15s opacity, 0.15s background;
  min-height: 48px;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, var(--primary), var(--primary2));
  color: white;
  width: 100%;
}

.btn-ok {
  background: linear-gradient(180deg, #34d399, #16a34a);
  color: #052e16;
}

.btn-warn {
  background: linear-gradient(180deg, #fbbf24, #d97706);
  color: #1c1403;
}

.btn-danger {
  background: linear-gradient(180deg, #f87171, #dc2626);
  color: white;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-pink {
  background: linear-gradient(180deg, #f472b6, #db2777);
  color: white;
}

.hint {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.hint code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 6px;
}

/* Shell */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(15, 20, 25, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.topbar .brand {
  font-weight: 800;
  font-size: 1.05rem;
}

.topbar .meta {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.topbar select {
  background: #0f1724;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 10px;
  min-height: 40px;
}

.main {
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  background: var(--card);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat .n {
  font-size: 1.4rem;
  font-weight: 800;
}

.stat .l {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar .search {
  flex: 1;
  min-width: 200px;
}

.toolbar input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0f1724;
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 1.1rem;
  min-height: 52px;
}

.slot-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chip {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
}

.chip.active {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--primary);
  color: #dbeafe;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow);
}

.card.highlight {
  border-color: rgba(59, 130, 246, 0.55);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.3), var(--shadow);
}

.card .unit {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.card .owner {
  color: var(--muted);
  margin-top: 4px;
}

.card .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #d6e4f5;
}

.tag.ok {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}
.tag.warn {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
}
.tag.danger {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}
.tag.blue {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

.card .ops {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.card .ops .btn {
  flex: 1;
  min-width: 110px;
  font-size: 0.95rem;
  padding: 12px 10px;
}

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

/* Modal */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: end center;
  z-index: 50;
  padding: 12px;
}

@media (min-width: 720px) {
  .modal-mask {
    place-items: center;
  }
}

.modal {
  width: min(520px, 100%);
  background: #1b2738;
  border-radius: 20px 20px 16px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 20px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow);
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.modal .desc {
  color: var(--muted);
  margin-bottom: 16px;
}

.modal .route-btns {
  display: grid;
  gap: 10px;
}

.modal .route-btns .btn {
  font-size: 1.1rem;
  min-height: 56px;
}

.modal .foot {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.modal .foot .btn {
  flex: 1;
}

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

.check-item {
  display: flex;
  gap: 12px;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.check-item input {
  width: 22px;
  height: 22px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #111827;
  color: white;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 100;
  max-width: 90vw;
  box-shadow: var(--shadow);
}

.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 14px;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

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

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(59, 130, 246, 0.15);
  color: #bfdbfe;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 700;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 8px 0 12px;
}

.two-col {
  display: grid;
  gap: 12px;
}

@media (min-width: 900px) {
  .two-col {
    grid-template-columns: 1fr 1fr;
  }
}
