/* JIAMU CRM — 设计系统 */

:root {
  --brand-50: #f0fdfa;
  --brand-100: #ccfbf1;
  --brand-200: #99f6e4;
  --brand-500: #14b8a6;
  --brand-600: #0d9488;
  --brand-700: #0f766e;
  --brand-800: #115e59;
  --brand-900: #134e4a;

  --accent-500: #d97706;
  --accent-600: #b45309;

  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --ink-50: #f8fafc;

  --success-600: #16a34a;
  --success-50: #f0fdf4;
  --warning-600: #d97706;
  --warning-50: #fffbeb;
  --danger-600: #dc2626;
  --danger-50: #fef2f2;
  --info-600: #2563eb;
  --info-50: #eff6ff;

  --sidebar-bg: #0b1320;
  --sidebar-bg-active: #132033;
  --sidebar-text: #cbd5e1;
  --sidebar-text-active: #ffffff;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);

  --sidebar-w: 232px;
  --topbar-h: 62px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--ink-50);
  color: var(--ink-900);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0 0 8px; }
ul { margin: 0; padding: 0; list-style: none; }
hr { border: none; border-top: 1px solid var(--ink-200); margin: 16px 0; }
::selection { background: var(--brand-200); }

/* ---------- Layout ---------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  color: #fff;
}
.sidebar-brand .logo-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-800));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff;
  box-shadow: 0 2px 8px rgba(20, 184, 166, 0.35);
}
.sidebar-brand .name { font-size: 15px; font-weight: 700; line-height: 1.2; }
.sidebar-brand .sub { font-size: 11px; color: var(--ink-400); }

.sidebar-nav { flex: 1; padding: 6px 12px; overflow-y: auto; }
.sidebar-nav .nav-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-500); padding: 14px 10px 6px;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-size: 13.5px; font-weight: 500;
  margin-bottom: 2px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.sidebar-nav a.active { background: var(--sidebar-bg-active); color: var(--sidebar-text-active); }
.sidebar-nav a .icon { width: 18px; text-align: center; opacity: 0.9; }

.sidebar-foot {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px; color: var(--ink-500);
}

.main-area { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--ink-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; margin: 0; }
.topbar .crumb { font-size: 12.5px; color: var(--ink-500); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-100); color: var(--brand-800);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px;
}
.user-chip .meta { line-height: 1.25; }
.user-chip .meta .name { font-size: 13px; font-weight: 600; color: var(--ink-900); }
.user-chip .meta .role { font-size: 11px; color: var(--ink-500); }

.content { padding: 24px; flex: 1; max-width: 1320px; width: 100%; margin: 0 auto; }

/* ---------- Flash / alerts ---------- */

.flash-stack { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.alert {
  padding: 11px 16px; border-radius: var(--radius); font-size: 13.5px;
  display: flex; align-items: center; gap: 8px; border: 1px solid transparent;
}
.alert-success { background: var(--success-50); color: #166534; border-color: #bbf7d0; }
.alert-danger { background: var(--danger-50); color: #991b1b; border-color: #fecaca; }
.alert-info { background: var(--info-50); color: #1e40af; border-color: #bfdbfe; }
.alert-warning { background: var(--warning-50); color: #92400e; border-color: #fde68a; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer; line-height: 1.3;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand-700); color: #fff; }
.btn-primary:hover { background: var(--brand-800); color: #fff; }
.btn-secondary { background: #fff; color: var(--ink-700); border-color: var(--ink-200); }
.btn-secondary:hover { background: var(--ink-100); color: var(--ink-900); }
.btn-ghost { background: transparent; color: var(--ink-600); }
.btn-ghost:hover { background: var(--ink-100); color: var(--ink-900); }
.btn-danger { background: #fff; color: var(--danger-600); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger-50); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-icon { padding: 7px 9px; }

/* ---------- Cards ---------- */

.card {
  background: #fff; border: 1px solid var(--ink-200); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--ink-200);
}
.card-header h3 { font-size: 14.5px; }
.card-header .desc { font-size: 12px; color: var(--ink-500); margin-top: 2px; }

.grid { display: grid; gap: 16px; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1080px) {
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: #fff; border: 1px solid var(--ink-200); border-radius: var(--radius-lg);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 6px;
}
.stat-card .stat-label { font-size: 12.5px; color: var(--ink-500); font-weight: 600; display:flex; align-items:center; gap:6px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; color: var(--ink-900); }
.stat-card .stat-hint { font-size: 12px; color: var(--ink-500); }
.stat-card .stat-hint.warn { color: var(--danger-600); font-weight: 600; }
.stat-card .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; background: #fff; }
table.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-500); font-weight: 700; padding: 10px 14px; background: var(--ink-50);
  border-bottom: 1px solid var(--ink-200); white-space: nowrap;
}
table.table td { padding: 11px 14px; border-bottom: 1px solid var(--ink-100); vertical-align: middle; }
table.table tbody tr:hover { background: var(--brand-50); }
table.table tbody tr:last-child td { border-bottom: none; }
table.table .num { text-align: right; font-variant-numeric: tabular-nums; }
table.table a.row-link { color: var(--ink-900); font-weight: 600; }
table.table a.row-link:hover { color: var(--brand-700); }
.cell-muted { color: var(--ink-500); }
.cell-overdue { color: var(--danger-600); font-weight: 700; }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2.5px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  white-space: nowrap; line-height: 1.6;
}
.badge-muted { background: var(--ink-100); color: var(--ink-600); }
.badge-brand { background: var(--brand-100); color: var(--brand-800); }
.badge-success { background: var(--success-50); color: #15803d; }
.badge-success-solid { background: var(--success-600); color: #fff; }
.badge-warning { background: var(--warning-50); color: #b45309; }
.badge-danger { background: var(--danger-50); color: #b91c1c; }
.badge-info { background: var(--info-50); color: #1d4ed8; }

/* ---------- Forms ---------- */

label { display: block; font-size: 12.5px; font-weight: 650; color: var(--ink-700); margin-bottom: 5px; }
.field-hint { font-size: 11.5px; color: var(--ink-500); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=tel], input[type=file],
select, textarea {
  width: 100%; padding: 8.5px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--ink-200); background: #fff; color: var(--ink-900);
  font-size: 13.5px; font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100);
}
textarea { resize: vertical; min-height: 72px; }
.form-row { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 720px) {
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
}
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-weight: 500; color: var(--ink-900); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.search-bar .grow { flex: 1; min-width: 180px; }
.search-bar select, .search-bar input { min-width: 140px; }

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--ink-200); margin-bottom: 20px; overflow-x: auto; }
.tabs a {
  padding: 11px 16px; font-size: 13.5px; font-weight: 650; color: var(--ink-500);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--ink-900); text-decoration: none; }
.tabs a.active { color: var(--brand-700); border-color: var(--brand-700); }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 640px; margin: auto;
}
.modal.modal-wide { max-width: 880px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--ink-200); }
.modal-head h3 { font-size: 15.5px; }
.modal-body { padding: 20px 22px; max-height: 72vh; overflow-y: auto; }
.modal-close { cursor: pointer; color: var(--ink-400); font-size: 20px; line-height: 1; background: none; border: none; }
.modal-close:hover { color: var(--ink-900); }

/* ---------- Misc components ---------- */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; gap: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 19px; }
.page-head .desc { color: var(--ink-500); font-size: 13px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--ink-500); }
.empty-state .glyph { font-size: 30px; margin-bottom: 8px; }

.section-title { font-size: 13px; font-weight: 700; color: var(--ink-700); margin: 22px 0 10px; text-transform: uppercase; letter-spacing: .03em; }
.section-title:first-child { margin-top: 0; }

.detail-header {
  background: #fff; border: 1px solid var(--ink-200); border-radius: var(--radius-lg);
  padding: 20px 22px; margin-bottom: 20px; box-shadow: var(--shadow-sm);
}
.detail-header .top-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.detail-header .code { font-size: 12px; color: var(--ink-500); font-weight: 700; letter-spacing: .03em; }
.detail-header h2 { font-size: 20px; margin: 2px 0 8px; }
.detail-header .badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.kv-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 16px; }
.kv-grid .kv-label { font-size: 11px; color: var(--ink-500); text-transform: uppercase; letter-spacing: .03em; }
.kv-grid .kv-value { font-size: 13.5px; font-weight: 600; color: var(--ink-900); margin-top: 2px; }
@media (max-width: 900px) { .kv-grid { grid-template-columns: repeat(2, 1fr); } }

.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--ink-100); }
.timeline-item:last-child { border-bottom: none; }
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand-500); margin-top: 6px; flex-shrink: 0; }
.timeline-body { flex: 1; }
.timeline-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.timeline-head .who { font-weight: 700; font-size: 13px; }
.timeline-head .when { font-size: 11.5px; color: var(--ink-500); }
.timeline-body .line { font-size: 13px; margin-top: 3px; }
.timeline-body .label { color: var(--ink-500); font-weight: 600; }

.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; border: 1px solid var(--ink-200); border-radius: var(--radius-sm); background: #fff;
}
.file-row .file-meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file-row .file-icon { width: 32px; height: 32px; border-radius: 8px; background: var(--brand-100); color: var(--brand-800); display:flex; align-items:center; justify-content:center; font-size: 14px; flex-shrink:0; }
.file-row .file-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .file-sub { font-size: 11.5px; color: var(--ink-500); }

.quote-version-card { border: 1px solid var(--ink-200); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.quote-version-card.is-latest { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }
.quote-version-card .qv-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.quote-version-card .qv-price { font-size: 20px; font-weight: 700; color: var(--brand-800); }
.quote-version-card .qv-price small { font-size: 12px; color: var(--ink-500); font-weight: 500; }

.label { font-weight: 700; color: var(--ink-700); }
.text-muted { color: var(--ink-500); }
.text-sm { font-size: 12.5px; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.wrap { flex-wrap: wrap; }

/* ---------- Auth pages ---------- */

.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at top, #16233a, #0b1320 65%);
  padding: 20px;
}
.auth-card {
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 400px; padding: 34px 32px;
}
.auth-card .logo-mark {
  width: 46px; height: 46px; border-radius: 12px; margin-bottom: 14px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-800));
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 19px;
}
.auth-card h1 { font-size: 19px; }
.auth-card .sub { color: var(--ink-500); font-size: 13px; margin-bottom: 22px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 12px; color: rgba(255,255,255,0.55); }

/* ---------- Print ---------- */

@media print {
  .sidebar, .topbar, .page-head .actions, .tabs, .no-print { display: none !important; }
  .main-area { margin-left: 0; }
}
