:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: #d8e1ec;
  --text: #1b2430;
  --muted: #65758a;
  --primary: #1f6feb;
  --primary-weak: #e8f1ff;
  --ok: #138a55;
  --warn: #b7791f;
  --danger: #c2410c;
  --sidebar: #122033;
  --radius: 8px;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button, input, select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
}

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

button.ghost {
  background: transparent;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

input, select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff;
  color: var(--text);
}

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

.loading-screen, .auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loading-screen {
  grid-template-columns: auto auto;
  gap: 16px;
}

.loading-screen h1, .auth-card h1 {
  margin: 0;
  font-size: 24px;
}

.loading-screen p, .auth-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
}

.auth-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 16px 40px rgba(35, 51, 75, .10);
  padding: 24px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 18px 0;
}

.auth-tabs button.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-weak);
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

.message {
  margin-top: 12px;
  min-height: 20px;
  color: var(--muted);
}

.message.error { color: var(--danger); }
.message.ok { color: var(--ok); }

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

.sidebar {
  background: var(--sidebar);
  color: #d8e4f2;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

.sidebar-head {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}

.sidebar-head .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 19px;
}

.sidebar-title {
  font-weight: 700;
}

.nav {
  padding: 12px 8px;
  display: grid;
  gap: 4px;
  align-content: start;
}

.nav button {
  justify-content: flex-start;
  text-align: left;
  border: 0;
  background: transparent;
  color: #d8e4f2;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.nav button.active {
  background: rgba(31, 111, 235, .28);
  color: #fff;
}

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.10);
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
}

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

.content {
  padding: 16px;
  overflow: auto;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric, .panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.metric {
  padding: 14px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.panel {
  margin-bottom: 14px;
}

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

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

.panel-body {
  padding: 14px;
}

.table-wrap {
  overflow: auto;
}

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

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

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--primary-weak);
  color: var(--primary);
}

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

.mobile-bar {
  display: none;
}

@media (max-width: 820px) {
  body {
    background: #fff;
  }

  .shell {
    display: block;
    padding-bottom: 64px;
  }

  .sidebar {
    display: none;
  }

  .main {
    min-height: 100vh;
    grid-template-rows: 54px minmax(0, 1fr);
  }

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

  .topbar h1 {
    font-size: 16px;
  }

  .install-label, .desktop-only {
    display: none;
  }

  .content {
    padding: 12px;
  }

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

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

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-head > div {
    width: 100%;
  }

  .mobile-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 58px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: #fff;
    border-top: 1px solid var(--line);
    z-index: 20;
  }

  .mobile-bar button {
    border: 0;
    border-radius: 0;
    display: grid;
    place-items: center;
    gap: 2px;
    color: var(--muted);
    font-size: 12px;
  }

  .mobile-bar button.active {
    color: var(--primary);
    background: var(--primary-weak);
  }

  table {
    min-width: 640px;
  }
}
