:root {
  --bg: #edf5fd;
  --surface: #ffffff;
  --ink: #10233d;
  --muted: #66788e;
  --line: #d6e5f4;
  --navy: #061a33;
  --blue: #1f7cff;
  --cyan: #18c8ff;
  --red: #c24135;
  --amber: #a86508;
  --green: #25734b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% -10%, rgba(31, 124, 255, 0.16), transparent 32%),
    var(--bg);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button { cursor: pointer; }

.hidden { display: none !important; }

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 8%, rgba(24, 200, 255, 0.18), transparent 28%),
    linear-gradient(145deg, #061a33, #0a2d52 68%, #071f3b);
}

.login-brand {
  position: absolute;
  top: max(36px, 8vh);
  color: #f3f9ff;
  text-align: center;
}

.login-brand h1 { margin: 14px 0 6px; font-size: 30px; }
.login-brand p { margin: 0; color: #9fc5e7; font-size: 13px; }

.brand-mark {
  display: grid;
  width: 58px;
  height: 48px;
  margin: 0 auto;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--cyan), var(--blue) 62%, #0c5ed7);
  box-shadow: 0 12px 30px rgba(31, 124, 255, 0.38);
  font-weight: 800;
}

.login-card {
  display: grid;
  width: min(390px, 100%);
  gap: 15px;
  padding: 26px;
  border: 1px solid rgba(120, 195, 255, 0.25);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.login-card label,
.account-form label {
  display: grid;
  gap: 7px;
  color: #61748b;
  font-size: 12px;
}

.login-card input,
.account-form input,
.task-form input,
.task-form select,
.task-form textarea,
.user-form input,
.user-form select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: #fff;
}

.login-card button,
.task-form button,
.account-form button,
.user-form button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #0d99ef);
  font-weight: 650;
}

.login-error { min-height: 18px; color: var(--red); font-size: 12px; }

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

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  background:
    radial-gradient(circle at 0 0, rgba(31, 124, 255, 0.38), transparent 36%),
    var(--navy);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 7px 22px;
}

.brand .brand-mark { width: 48px; height: 38px; margin: 0; }
.brand strong,
.brand span { display: block; }
.brand span { margin-top: 3px; color: #9fb8d1; font-size: 11px; }

.sidebar nav { display: grid; gap: 5px; }

.sidebar nav button,
.mobile-nav button {
  border: 0;
  border-radius: 8px;
  color: #c8d6e6;
  background: transparent;
  text-align: left;
}

.sidebar nav button {
  width: 100%;
  padding: 11px 12px;
}

.sidebar nav button.active {
  color: #fff;
  background: rgba(31, 124, 255, 0.25);
  box-shadow: inset 3px 0 var(--cyan);
}

.logout-button {
  margin-top: auto;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #c8d6e6;
  background: rgba(255, 255, 255, 0.04);
}

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

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

.topbar h1 { margin: 0; font-size: 24px; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.top-user { text-align: right; }
.top-user strong,
.top-user span { display: block; }
.top-user span { margin-top: 4px; color: var(--muted); font-size: 11px; }

.page { display: none; }
.page.active { display: block; }

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

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(20, 75, 140, 0.08);
}

.metric-card {
  position: relative;
  overflow: hidden;
  padding: 17px;
}

.metric-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  content: "";
}

.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { margin-top: 8px; font-size: 26px; font-weight: 800; }
.metric-note { margin-top: 6px; color: var(--muted); font-size: 10px; }

.panel { margin-bottom: 14px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 17px 18px 12px;
}

.panel-head h2 { margin: 0; font-size: 16px; }
.panel-head span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }

.map-panel {
  overflow: hidden;
  border-color: #153e68;
  background:
    linear-gradient(rgba(60, 149, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(60, 149, 255, 0.05) 1px, transparent 1px),
    linear-gradient(145deg, #071d38, #09284a 72%, #0b3159);
  background-size: 26px 26px, 26px 26px, auto;
}

.map-panel .panel-head h2 { color: #f2f9ff; }
.map-panel .panel-head span { color: #8fb6d9; }
.map-status { display: flex; flex-wrap: wrap; gap: 7px; color: #9fd5f7; font-size: 10px; }
#china-map { width: 100%; height: 430px; }

.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th {
  position: sticky;
  top: 0;
  padding: 10px 12px;
  color: var(--muted);
  background: #f1f7fe;
  text-align: left;
  white-space: nowrap;
}
td { padding: 11px 12px; border-top: 1px solid #edf2f7; vertical-align: middle; }
.store-name { font-weight: 700; }
.store-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }

.compact-search {
  width: min(280px, 45vw);
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.task-form,
.user-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 16px 16px;
}

.task-form textarea,
.task-form button,
.user-form button { grid-column: 1 / -1; }

.task-list { display: grid; gap: 9px; padding: 0 16px 16px; }

.task-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 11px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.task-item h3 { margin: 0; font-size: 13px; }
.task-item p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.task-priority { padding: 4px 7px; border-radius: 999px; background: #e5f2ff; color: var(--blue); font-size: 9px; font-weight: 800; }
.task-priority.P0 { color: #fff; background: var(--red); }
.task-priority.P1 { color: #fff; background: var(--amber); }
.task-status { font-size: 10px; color: var(--muted); }

.asset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 16px 16px;
}

.asset-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbff;
}

.asset-card img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: contain;
  background: #fff;
}

.asset-card strong { display: block; padding: 10px 12px 12px; font-size: 11px; }

.narrow-panel { max-width: 700px; }
.account-form { display: grid; gap: 12px; padding: 0 16px 16px; }

.user-list { display: grid; gap: 8px; padding: 0 16px 16px; }
.user-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}
.user-item strong, .user-item span { display: block; }
.user-item span { margin-top: 4px; color: var(--muted); font-size: 10px; }

.empty {
  display: grid;
  min-height: 130px;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.mobile-nav { display: none; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  max-width: 420px;
  padding: 12px 15px;
  border-radius: 8px;
  color: #fff;
  background: #0d65b8;
  box-shadow: 0 12px 40px rgba(20, 32, 48, 0.25);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: #9c342b; }

@media (max-width: 760px) {
  .app-shell { display: block; padding-bottom: 72px; }
  .sidebar { display: none; }
  main { padding: 16px 13px 25px; }
  .topbar h1 { font-size: 21px; }
  .top-user { display: none; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #china-map { height: 330px; }
  .panel-head { align-items: flex-start; }
  .asset-grid { grid-template-columns: 1fr; }
  .task-form,
  .user-form { grid-template-columns: 1fr; }
  .compact-search { width: 42vw; }
  .mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
    border-top: 1px solid #cfdfef;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
  }
  .mobile-nav button {
    padding: 8px 2px;
    color: #60758d;
    text-align: center;
    font-size: 11px;
  }
  .mobile-nav button.active { color: var(--blue); background: #eaf4ff; }
  .login-brand { position: static; margin-bottom: 18px; }
}
