/* 外贸站 SaaS 前端样式（v0.2.0，零依赖，纯 CSS）。
   设计 token 来自管理后台原型：背景 #f4f6f5、品牌绿 #0e7a5f、圆角 14px。
   字体只用系统字体栈，不引外部字体（国内工厂客户经 CF 海外访问已偏慢，不再加外部依赖）。 */

:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --text: #14201c;
  --muted: #4c5b55;
  --muted-2: #84938c;
  --border: #dde5e1;
  --accent: #0e7a5f;
  --accent-dark: #0a5c48;
  --accent-light: #e2f2ec;
  --amber: #b97a12;
  --amber-bg: #fdf3dd;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --blue: #1d5fa8;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

a {
  color: var(--accent);
}

code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- 顶栏（静态页眉） ---------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  gap: 12px;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.nav a {
  text-decoration: none;
  white-space: nowrap;
}

/* ---------- 布局：232px 侧栏 + 主区 ---------- */

.shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  gap: 24px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 30px 60px;
}

.sidebar {
  position: sticky;
  top: 24px;
  align-self: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-block {
  padding: 4px 8px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

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

.nav-group {
  display: flex;
  flex-direction: column;
}

.nav-title {
  margin: 10px 8px 4px;
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
}

.nav-link:hover {
  background: var(--accent-light);
}

.nav-link.active {
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 700;
}

.nav-badge {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

.nav-btn {
  width: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.sidebar-note {
  margin: 0 8px 8px;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.5;
}

.main {
  min-width: 0;
}

main.container {
  padding-top: 24px;
  padding-bottom: 48px;
}

/* ---------- 卡片与通用 ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 2px rgb(20 32 28 / 0.04);
}

.card + .card {
  margin-top: 16px;
}

h1 {
  margin: 0;
  font-size: 22px;
}

h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

h3 {
  margin: 16px 0 8px;
  font-size: 15px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 22px;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
}

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

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

.banner {
  padding: 10px 12px;
  border: 1px dashed var(--amber);
  border-radius: 8px;
  background: var(--amber-bg);
  color: #6d4a08;
  margin: 0 0 16px;
}

.form {
  display: grid;
  gap: 16px;
}

.form label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  background: var(--surface);
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-dark);
}

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

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar input[type="search"] {
  max-width: 320px;
}

/* ---------- 登录 ---------- */

.login-card {
  max-width: 520px;
  margin: 24px auto;
}

.login-card hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ---------- KPI 与分栏 ---------- */

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

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.kpi-label {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.kpi-value {
  margin: 4px 0;
  font-size: 26px;
  font-weight: 700;
}

.kpi-sub {
  margin: 0;
  color: var(--muted-2);
  font-size: 13px;
}

.two-col,
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.card-grid .card + .card {
  margin-top: 0;
}

.two-col .card + .card {
  margin-top: 0;
}

.arch-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.arch-cell {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.plans-grid {
  grid-template-columns: repeat(3, 1fr);
}

.plan-card {
  display: flex;
  flex-direction: column;
}

.plan-featured {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.plan-price {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-dark);
  margin: 4px 0 8px;
}

/* ---------- 表格 ---------- */

.table-wrap {
  overflow-x: auto;
  margin: 8px 0 16px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2f5;
  font-size: 13px;
  white-space: nowrap;
}

.badge-pending {
  background: var(--amber-bg);
  color: #7a5b00;
}

/* ---------- 空状态 / 详情 ---------- */

.empty {
  padding: 32px 16px;
  text-align: center;
}

.empty-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
}

.kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 16px;
  margin: 16px 0;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

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

.footer {
  padding: 16px 0 32px;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- 移动端底部导航 ---------- */

.bottom-nav,
.more-drawer {
  display: none;
}

/* ---------- 移动端 ---------- */

@media (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

@media (max-width: 760px) {
  .topbar-inner {
    min-height: 52px;
  }

  .nav {
    gap: 10px;
    font-size: 14px;
  }

  .shell {
    grid-template-columns: 1fr;
    padding: 16px 16px 96px;
    gap: 0;
  }

  .sidebar {
    display: none;
  }

  .two-col,
  .card-grid,
  .plans-grid {
    grid-template-columns: 1fr;
  }

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

  .kv {
    grid-template-columns: 88px 1fr;
  }

  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }

  .bottom-link {
    padding: 8px 2px;
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
  }

  .bottom-link.active {
    color: var(--accent-dark);
    font-weight: 700;
  }

  .more-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 24px rgb(20 32 28 / 0.12);
  }

  .more-drawer[hidden] {
    display: none;
  }

  .more-drawer a,
  .more-drawer button {
    padding: 12px 4px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-size: 15px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
  }

  /* 移动端表格改为卡片式行 */
  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table thead {
    display: none;
  }

  .table tr {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 4px 0;
  }

  .table td {
    border-bottom: 0;
    padding: 6px 12px;
  }
}
