/* ============================================================
   外贸单证与报关一体化系统 — 界面样式
   单证版式在 print.css
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #1a4d8f;
  --primary-dark: #123a6b;
  --primary-light: #2c6fc4;
  --primary-soft: #eaf1fa;
  --accent: #d97706;
  --success: #15803d;
  --danger: #b91c1c;
  --warn: #b45309;
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #dfe4ec;
  --text: #1f2937;
  --text-soft: #6b7280;
  --sidebar-bg: #14304f;
  --sidebar-hover: #1c4267;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 216px;
  height: 100vh;
  background: var(--sidebar-bg);
  color: #cbd8e8;
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
  flex-shrink: 0;
}
.sidebar-brand .logo {
  width: 38px; height: 38px; flex-shrink: 0;
  background: linear-gradient(135deg, #2c6fc4, #1a4d8f);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; color: #fff; font-size: 15px;
  letter-spacing: .5px;
}
.sidebar-brand b { color: #fff; font-size: 12.5px; line-height: 1.35; font-weight: 600; }

.nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px 0 16px; }
.nav::-webkit-scrollbar { width: 5px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 3px; }

.nav-group { margin-bottom: 6px; }
.nav-group-title {
  padding: 10px 16px 5px;
  font-size: 11px;
  color: #7d94b0;
  letter-spacing: 1px;
  font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px 8px 22px;
  font-size: 13.5px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .14s, border-color .14s;
  position: relative;
}
.nav-item::before {
  content: ''; width: 4px; height: 4px; border-radius: 50%;
  background: #4a6d94; flex-shrink: 0;
  transition: background .14s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active {
  background: var(--sidebar-hover);
  color: #fff;
  border-left-color: var(--primary-light);
  font-weight: 500;
}
.nav-item.active::before { background: #6fb0ff; }

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, .09);
  font-size: 11.5px;
  color: #7d94b0;
  line-height: 1.6;
  flex-shrink: 0;
}

.main { flex: 1; margin-left: 216px; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 58px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-left h2 { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.mobile-toggle {
  display: none;
  background: none; border: none; font-size: 20px; color: var(--text);
  padding: 4px 8px;
}

.user-chip { display: flex; align-items: center; gap: 8px; margin-right: 4px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.user-meta .uname { font-size: 13px; font-weight: 500; line-height: 1.3; }
.user-meta .urole { font-size: 11px; color: var(--text-soft); }

.content { padding: 18px 20px 40px; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius);
  font-size: 13.5px;
  transition: all .14s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary-light); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-accent { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-accent:hover { background: #991b1b; border-color: #991b1b; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: #f0f3f8; color: var(--primary); border-color: transparent; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.card-head h3 { font-size: 14.5px; font-weight: 600; }
.card-body { padding: 16px; }

/* ---------------- 页面头 ---------------- */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.page-head h2 { font-size: 18px; font-weight: 600; }
.page-head .sub { font-size: 12.5px; color: var(--text-soft); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 工具栏 ---------------- */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar input[type=text], .toolbar select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  min-width: 140px;
}
.toolbar input[type=text] { min-width: 210px; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--primary-light); }

/* ---------------- 表单 ---------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; color: var(--text-soft); font-weight: 500; }
.field label .req { color: var(--danger); }
.field input, .field select, .field textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .14s;
  background: #fff;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(44, 111, 196, .1);
}
.field textarea { resize: vertical; min-height: 66px; line-height: 1.55; }
.field-full { grid-column: 1 / -1; }
.field-hint { font-size: 11.5px; color: var(--text-soft); }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th {
  text-align: left;
  padding: 10px 12px;
  background: #f7f9fc;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-soft);
  white-space: nowrap;
  font-size: 12.5px;
}
table.data td {
  padding: 10px 12px;
  border-bottom: 1px solid #eef1f6;
  vertical-align: middle;
}
table.data tbody tr:hover { background: #fafcff; }
table.data .r { text-align: right; }
table.data .c { text-align: center; }
table.data .actions { white-space: nowrap; }
table.data .actions .btn { margin-right: 5px; }

.empty-pane {
  padding: 46px 20px;
  text-align: center;
  color: var(--text-soft);
  font-size: 13.5px;
}

/* ---------------- 标签 ---------------- */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.6;
}
.tag-blue { background: #e3eefb; color: #1a4d8f; }
.tag-green { background: #e5f5ea; color: var(--success); }
.tag-orange { background: #fdf1e0; color: var(--warn); }
.tag-red { background: #fdeaea; color: var(--danger); }
.tag-gray { background: #eef1f5; color: var(--text-soft); }

/* ---------------- 工作台：左编辑 / 右预览 ---------------- */
.workbench { display: grid; grid-template-columns: 400px 1fr; gap: 16px; align-items: start; }

.panel-tabs {
  display: flex; gap: 2px; padding: 0 12px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.panel-tabs button {
  border: none; background: none;
  padding: 11px 12px;
  font-size: 13.5px;
  color: var(--text-soft);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all .14s;
}
.panel-tabs button:hover { color: var(--primary); }
.panel-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* 单证明细编辑行 */
.item-row {
  display: grid;
  grid-template-columns: 1fr 62px 66px 66px 30px;
  gap: 6px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed #e6eaf1;
}
.item-row input {
  padding: 6px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  outline: none;
  width: 100%;
  font-size: 13px;
}
.item-row input:focus { border-color: var(--primary-light); }
.item-row .del {
  border: none; background: none; color: var(--danger);
  font-size: 16px; padding: 2px; line-height: 1;
}
.item-head {
  display: grid;
  grid-template-columns: 1fr 62px 66px 66px 30px;
  gap: 6px;
  font-size: 11.5px; color: var(--text-soft);
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

/* 预览区 */
.preview-wrap { position: relative; }
.preview-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 9px 12px; gap: 10px; flex-wrap: wrap;
  border-bottom: none;
}
.doc-tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.doc-tabs button {
  border: 1px solid transparent; background: none;
  padding: 5px 11px; font-size: 13px; border-radius: 4px;
  color: var(--text-soft); transition: all .14s;
}
.doc-tabs button:hover { background: #f0f4fa; color: var(--primary); }
.doc-tabs button.active {
  background: var(--primary); color: #fff; font-weight: 500;
}
.preview-toolbar-right { display: flex; align-items: center; gap: 8px; }

.paper-scroll {
  background: #e9edf3;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 20px 12px;
  max-height: calc(100vh - 200px);
  overflow: auto;
}

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 23, 42, .48);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 46px 16px;
  overflow-y: auto;
  animation: fadeIn .16s;
}
.modal {
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 620px;
  animation: pop .18s;
}
.modal.wide { max-width: 900px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 15.5px; font-weight: 600; }
.modal-close {
  border: none; background: none; font-size: 21px;
  color: var(--text-soft); line-height: 1; padding: 0 4px;
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 18px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 13px 18px;
  border-top: 1px solid var(--border);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(.97) translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- Toast ---------------- */
.toast-wrap {
  position: fixed; top: 18px; right: 18px; z-index: 90;
  display: flex; flex-direction: column; gap: 9px;
}
.toast {
  background: #1f2937; color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  animation: slideIn .2s;
  max-width: 340px;
}
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }
.toast.warn { background: var(--warn); }
@keyframes slideIn { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- 加载 ---------------- */
.loading-pane {
  padding: 60px 20px; text-align: center;
  color: var(--text-soft); font-size: 13.5px;
}
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
  vertical-align: middle; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 条款卡片 ---------------- */
.clause-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  background: #fbfcfe;
}
.clause-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; gap: 8px;
}
.clause-card-head b { font-size: 13.5px; color: var(--primary); }
.clause-cat {
  font-size: 11px; color: var(--text-soft);
  background: #eef1f6; padding: 1px 7px; border-radius: 9px;
}
/* 待填提醒 */
.clause-card.has-blank { border-color: #fbd38d; background: #fffdf7; }
.clause-warn {
  font-size: 11px; color: #92400e; background: #fef3c7;
  padding: 1px 7px; border-radius: 9px; margin-left: 5px;
}
.req-mark {
  font-size: 10.5px; color: #b91c1c; background: #fee2e2;
  padding: 1px 5px; border-radius: 4px; margin-left: 4px; font-weight: 500;
}
input.need-fill, select.need-fill {
  border-color: #f6ad55 !important;
  background: #fffaf0 !important;
}
input.need-fill:focus, select.need-fill:focus {
  border-color: var(--primary-light) !important;
  box-shadow: 0 0 0 3px rgba(44, 111, 196, .13);
}

/* ---------------- 明细表 ---------------- */
.summary-bar {
  display: flex; gap: 18px; flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--primary-soft);
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 10px;
}
.summary-bar b { color: var(--primary); }

/* ============================================================
   登录页
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  background:
    radial-gradient(1100px 520px at 12% -10%, #1e5aa8 0%, transparent 58%),
    radial-gradient(900px 470px at 108% 108%, #0f2a47 0%, transparent 55%),
    linear-gradient(150deg, #14304f 0%, #1a4d8f 58%, #123a6b 100%);
}

.login-card {
  width: 100%;
  max-width: 392px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(6, 20, 40, .34);
  padding: 34px 32px 26px;
}

.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .logo {
  width: 58px; height: 58px; margin: 0 auto 14px;
  background: linear-gradient(135deg, #2c6fc4, #1a4d8f);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: bold; font-size: 22px; letter-spacing: .5px;
  box-shadow: 0 6px 16px rgba(26, 77, 143, .32);
}
.login-brand h1 {
  font-size: 17.5px; font-weight: 700; color: #14304f;
  letter-spacing: .3px; margin-bottom: 5px;
}
.login-brand p {
  font-size: 11px; color: var(--text-soft);
  letter-spacing: .3px; line-height: 1.45;
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  line-height: 1.5;
}

.login-form .field { margin-bottom: 15px; }
.login-form .field label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: #374151; margin-bottom: 6px;
}
.login-form .field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: #fbfcfe;
}
.login-form .field input:focus {
  border-color: var(--primary-light);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(44, 111, 196, .13);
}

.login-btn {
  width: 100%;
  margin-top: 8px;
  padding: 11px 16px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #2c6fc4, #1a4d8f);
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 2px;
  transition: opacity .15s, transform .1s;
}
.login-btn:hover:not(:disabled) { opacity: .93; }
.login-btn:active:not(:disabled) { transform: translateY(1px); }
.login-btn:disabled { opacity: .68; cursor: not-allowed; letter-spacing: normal; }
.login-btn .spinner {
  width: 15px; height: 15px; margin-right: 6px;
  border-color: rgba(255, 255, 255, .45);
  border-top-color: #fff;
}

.login-foot {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #eef1f6;
  text-align: center;
  font-size: 11px;
  color: var(--text-soft);
  line-height: 1.55;
}

.beian-foot { margin-top: 4px; }

.beian-foot a,
.sidebar-foot a.beian-no {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}

.beian-foot a:hover,
.sidebar-foot a.beian-no:hover { opacity: .8; }

.sidebar-foot .copyright { margin-top: 4px; font-size: 10.5px; opacity: .75; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1100px) {
  .workbench { grid-template-columns: 1fr; }
  .paper-scroll { max-height: none; }
}
@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .mobile-toggle { display: block; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 14px 12px 32px; }
  .user-meta { display: none; }
}
