:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --bg-soft: #f9fafc;
  --panel: #ffffff;
  --panel-soft: #f7f9fc;
  --text: #24364d;
  --text-strong: #172b45;
  --muted: #6b7c93;
  --line: #d9e1ea;
  --line-soft: #e8edf3;
  --primary: #1769e0;
  --primary-hover: #0f5ccc;
  --primary-soft: #eef5ff;
  --primary-line: #b9d5ff;
  --danger: #d92d20;
  --danger-soft: #fff4f2;
  --success: #168a4a;
  --success-soft: #effaf4;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

body.customer-page {
  min-height: 100vh;
  background: var(--bg);
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

button,
.button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--primary);
  border-radius: 3px;
  background: var(--primary);
  color: #ffffff;
  padding: 5px 10px;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

button:hover,
.button:hover {
  color: #ffffff;
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  text-decoration: none;
}

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

button.secondary,
.button.secondary {
  background: #ffffff;
  color: var(--text-strong);
  border-color: var(--line);
}

button.secondary:hover,
.button.secondary:hover {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: var(--primary-line);
}

button.danger,
.button.danger {
  background: #ffffff;
  color: var(--danger);
  border-color: #f2b8b5;
}

button.danger:hover,
.button.danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #ea8f89;
}

input,
select {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 5px 8px;
  font: inherit;
  background: #ffffff;
  color: var(--text);
  outline: none;
  box-shadow: none;
}

input::placeholder {
  color: #98a6b7;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px #e7f0ff;
}

code {
  padding: 1px 5px;
  border: 1px solid #d6e6ff;
  border-radius: 3px;
  background: #f4f8ff;
  color: #1559bd;
  font-family: "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background: var(--bg);
}

.auth-card {
  width: min(360px, calc(100vw - 32px));
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 18px;
  box-shadow: none;
}

.auth-card h1 {
  margin: 0 0 6px;
  color: var(--text-strong);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.customer-login-card {
  margin: 56px auto 0;
}

.stack {
  display: grid;
  gap: 10px;
}

.stack label {
  display: grid;
  gap: 5px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.topbar {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}

.brand {
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 18px;
  margin-right: 8px;
  border-radius: 2px;
  background: var(--primary);
  vertical-align: -4px;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}

.topbar nav a {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: 3px;
  color: #53657b;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.topbar nav a:hover {
  background: var(--panel-soft);
  border-color: var(--line-soft);
  color: var(--text-strong);
}

.topbar nav a.active {
  background: var(--primary-soft);
  border-color: var(--primary-line);
  color: var(--primary);
}

.container {
  max-width: 1440px;
  margin: 12px auto;
  padding: 0 12px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--text-strong);
}

h1 {
  font-size: 20px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 15px;
  line-height: 1.35;
  font-weight: 700;
}

h3 {
  font-size: 13px;
  font-weight: 700;
}

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

.message {
  min-height: 18px;
  margin: 6px 0 8px;
  color: var(--primary);
  font-size: 12px;
}

.panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 10px;
  box-shadow: none;
}

.panel h2 {
  margin-bottom: 8px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 9px 10px;
  box-shadow: none;
}

.card span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.card strong {
  display: block;
  color: var(--text-strong);
  font-size: 19px;
  line-height: 1.25;
  font-weight: 750;
  letter-spacing: -0.025em;
}

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

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  align-items: end;
}

.copy-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.copy-row code {
  flex: 1;
  min-width: 220px;
  padding: 6px 8px;
  overflow-wrap: anywhere;
}

.api-box {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-soft);
}

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

.api-box code {
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
}

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

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  padding: 7px 8px;
  vertical-align: middle;
  white-space: nowrap;
}

td {
  color: var(--text);
}

th {
  color: #53657b;
  background: #f4f7fb;
  font-size: 12px;
  font-weight: 700;
}

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

tr:hover td {
  background: #fafcff;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.badge.ok {
  background: var(--success-soft);
  border-color: #bce8ce;
  color: var(--success);
}

.badge.off {
  background: var(--danger-soft);
  border-color: #f4c7c3;
  color: var(--danger);
}

.pricing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.pricing-count {
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid var(--primary-line);
  border-radius: 3px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 700;
}

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

.pricing-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 9px;
  box-shadow: none;
}

.pricing-card h3 {
  margin: 0 0 7px;
  color: var(--text-strong);
  font-size: 13px;
  line-height: 1.35;
  word-break: break-word;
}

.pricing-meta {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 4px 8px;
  font-size: 12px;
  line-height: 1.45;
}

.pricing-meta span:nth-child(odd) {
  color: var(--muted);
}

.pricing-meta span:nth-child(even) {
  color: var(--text);
  word-break: break-word;
  white-space: normal;
}

.empty-state {
  border: 1px dashed #c7d3df;
  border-radius: 4px;
  padding: 14px;
  text-align: center;
  color: var(--muted);
  background: #ffffff;
}

.toast-container {
  position: fixed;
  top: 56px;
  right: 12px;
  z-index: 99;
  display: grid;
  gap: 6px;
  width: min(340px, calc(100vw - 24px));
}

.toast {
  opacity: 0;
  transform: translateY(-4px);
  border-radius: 4px;
  padding: 9px 10px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: none;
  transition: opacity 150ms ease, transform 150ms ease;
  font-size: 12px;
  line-height: 1.45;
}

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

.toast.success,
.toast.info {
  border-color: var(--primary-line);
  background: var(--primary-soft);
  color: var(--primary);
}

.toast.error {
  border-color: #f2b8b5;
  background: var(--danger-soft);
  color: var(--danger);
}

@media (max-width: 720px) {
  body {
    font-size: 13px;
  }

  .topbar {
    height: auto;
    align-items: flex-start;
    padding: 10px 12px;
    flex-direction: column;
  }

  .topbar nav {
    width: 100%;
  }

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

  .container {
    margin: 10px auto;
    padding: 0 10px;
  }

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

  .pricing-meta {
    grid-template-columns: 72px minmax(0, 1fr);
  }
}
