/* ============================================================
   外贸客户工作台 — 样式
   ------------------------------------------------------------
   设计原则（按客户手册 §2.2 界面原则）：
     · 浅色、简约商务风格
     · 颜色只用于状态和风险，不做大面积装饰
     · 中文为主，字号偏小以保证列表信息密度
     · 列表横向简洁，一个单元格可用两行展示核心信息
     · 桌面端优先，移动端至少可用
   ============================================================ */

:root {
  --bg:        #f6f8fa;
  --surface:   #ffffff;
  --border:    #e3e8ee;
  --border-2:  #cbd5e1;
  --text:      #1f2937;
  --text-2:    #6b7280;
  --text-3:    #9ca3af;
  --nav-bg:    #1f3a5f;
  --nav-bg-2:  #17304f;
  --nav-text:  #cbd8e6;
  --accent:    #2563eb;
  --ok:        #16a34a;
  --warn:      #d97706;
  --danger:    #dc2626;
  --ok-bg:     #ecfdf5;
  --warn-bg:   #fffbeb;
  --danger-bg: #fef2f2;
  --info-bg:   #eff6ff;
  --radius:    8px;
  --sidebar-w: 208px;
}

* { box-sizing: border-box; }

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

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

/* ---------------- 布局 ---------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--nav-bg);
  color: var(--nav-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.09);
}
.brand-name {
  color: #fff; font-size: 15px; font-weight: 600; letter-spacing: .3px;
}
.brand-sub {
  color: var(--nav-text); font-size: 11px; opacity: .7; margin-top: 2px;
}

.nav { padding: 10px 0; flex: 1; }
.nav-group-title {
  padding: 12px 16px 5px;
  font-size: 10.5px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: rgba(255,255,255,.38);
}
.nav-item {
  display: block;
  padding: 7px 16px;
  color: var(--nav-text);
  font-size: 13px;
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: var(--nav-bg-2); color: #fff; text-decoration: none;
}
.nav-item.active {
  background: var(--nav-bg-2);
  border-left-color: #4f8ef7;
  color: #fff;
  font-weight: 500;
}
.nav-item.pending { opacity: .42; cursor: default; }
.nav-item.pending:hover { background: transparent; color: var(--nav-text); }
.nav-item .tag {
  float: right; font-size: 10px; opacity: .6; font-weight: 400;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 {
  font-size: 15px; font-weight: 600; margin: 0; color: var(--text);
}
.topbar .who { font-size: 12.5px; color: var(--text-2); }
.topbar .who a { color: var(--text-2); }

/* 移动端导航开关（汉堡）——桌面端由下方 @media 隐藏，不占位 */
.nav-toggle {
  display: none;
  width: 34px; height: 34px;
  margin-right: 10px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
}
.nav-toggle-bar {
  display: block;
  width: 15px; height: 1.6px;
  background: var(--text);
  border-radius: 1px;
}
.nav-toggle:active { background: var(--bg); }

/* 抽屉遮罩：仅移动端出现 */
.sidebar-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .38);
  z-index: 35;
}
.sidebar-mask[hidden] { display: none; }

.content { padding: 20px 22px 40px; max-width: 1320px; width: 100%; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.card-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-head h2 {
  font-size: 13.5px; font-weight: 600; margin: 0; color: var(--text);
}
.card-head .hint { font-size: 12px; color: var(--text-3); }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

/* ---------------- 统计块 ---------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .label { font-size: 12px; color: var(--text-2); }
.stat .value {
  font-size: 23px; font-weight: 600; margin-top: 4px;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.stat .sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.8px;
}
table.data th {
  text-align: left;
  padding: 9px 12px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
  position: sticky; top: 0;
}
table.data td {
  padding: 9px 12px;
  border-bottom: 1px solid #f0f3f6;
  vertical-align: top;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fafcfe; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .muted { color: var(--text-3); }
table.data .nowrap { white-space: nowrap; }
.cell-2line .line1 { font-weight: 500; }
.cell-2line .line2 { color: var(--text-2); font-size: 12px; }

/* ---------------- 标记 ---------------- */
.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11.5px;
  line-height: 1.7;
  white-space: nowrap;
}
.badge-ok      { background: var(--ok-bg);     color: var(--ok); }
.badge-warn    { background: var(--warn-bg);   color: var(--warn); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-info    { background: var(--info-bg);   color: var(--accent); }
.badge-muted   { background: #f3f4f6;          color: var(--text-2); }

/* ---------------- 表单 ---------------- */
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px;
}
.form-row .req { color: var(--danger); margin-left: 2px; }
.form-row .help {
  font-size: 11.5px; color: var(--text-3); margin-top: 4px; line-height: 1.5;
}
input[type=text], input[type=password], input[type=date], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.10);
}
input[type=file] {
  width: 100%; padding: 9px 10px;
  border: 1px dashed var(--border-2);
  border-radius: 6px; background: #fbfcfd; font-size: 12.5px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0 16px;
}

.btn {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn-primary:hover { background: #1d4ed8; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- 提示条 ---------------- */
.alert {
  padding: 11px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
  border: 1px solid transparent;
}
.alert-ok      { background: var(--ok-bg);     border-color: #a7f3d0; color: #065f46; }
.alert-warn    { background: var(--warn-bg);   border-color: #fde68a; color: #92400e; }
.alert-danger  { background: var(--danger-bg); border-color: #fecaca; color: #991b1b; }
.alert-info    { background: var(--info-bg);   border-color: #bfdbfe; color: #1e40af; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert li { margin: 2px 0; }

/* ---------------- 登录页 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef2f7 0%, #f6f8fa 100%);
  padding: 20px;
}
.login-box {
  width: 100%; max-width: 366px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 30px 26px;
  box-shadow: 0 4px 24px rgba(31,58,95,.07);
}
.login-box .logo { text-align: center; margin-bottom: 22px; }
.login-box .logo .t { font-size: 18px; font-weight: 600; color: var(--nav-bg); }
.login-box .logo .s { font-size: 12px; color: var(--text-3); margin-top: 3px; }

/* ---------------- 其他 ---------------- */
.empty {
  padding: 40px 20px; text-align: center; color: var(--text-3); font-size: 13px;
}
.kv { display: flex; flex-wrap: wrap; gap: 8px 26px; }
.kv > div { font-size: 12.8px; }
.kv .k { color: var(--text-2); }
.kv .v { color: var(--text); font-weight: 500; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    position: fixed; left: -220px; transition: left .22s ease;
    width: 208px; flex-basis: 208px;
    z-index: 40;                 /* 压在遮罩(35)之上 */
    box-shadow: 2px 0 14px rgba(15,23,42,.12);
  }
  .sidebar.open { left: 0; }
  .content { padding: 14px; }
  .topbar { padding: 0 14px; }
  .nav-toggle { display: flex; }  /* 仅窄屏出现 */
  .topbar h1 { flex: 1; min-width: 0; overflow: hidden;
               text-overflow: ellipsis; white-space: nowrap; }
}
