/* ==========================================================================
   整一票 组件样式 components.css  v1.0
   依赖：tokens.css（必须先引入）
   唯一真源：本文件；通过 scripts/sync_design_source.mjs 单向同步设计源
   说明：本文件仅含通用组件；页面自身布局（介绍页区块、后台 shell）见对应页面样式
   ========================================================================== */

/* >>> design-source-sync:start */
/* ====================================================================
     组件层样式：依赖 tokens.css，开发可直接复制本节
     ==================================================================== */
  *, *::before, *::after { box-sizing: border-box; }
  body {
    margin: 0; font-family: var(--font-sans); font-size: var(--fs-body);
    color: var(--ink); background: var(--bg); line-height: var(--lh-body);
    -webkit-font-smoothing: antialiased;
  }
  a { color: inherit; text-decoration: none; }

  /* ====================================================================
     1. Logo 与品牌
     ==================================================================== */
  .brand { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--fs-title); font-weight: 800; letter-spacing: -0.02em; }
  .brand-mark {
    display: grid; width: 32px; height: 32px; place-items: center; flex: none;
    border-radius: 9px; color: #fff; font-size: var(--fs-body); font-weight: 900;
    background: linear-gradient(135deg, var(--blue-400), var(--blue-600));
    box-shadow: 0 4px 12px rgba(11, 107, 255, .32);
  }
  .brand-mark.lg { width: 40px; height: 40px; border-radius: 11px; font-size: 18px; }
  .brand-mark.sm { width: 26px; height: 26px; border-radius: 7px; font-size: 12px; }

  /* ====================================================================
     2. 按钮
     ==================================================================== */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: var(--control-h); padding: 0 var(--space-5); border-radius: var(--radius-btn);
    font-size: var(--fs-body); font-weight: var(--fw-bold); font-family: inherit;
    border: 1.5px solid transparent; cursor: pointer; white-space: nowrap;
    transition: transform var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease),
                box-shadow var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease);
  }
  .btn:hover { transform: translateY(-1px); }
  .btn:active { transform: translateY(0); }
  .btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
  .btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

  .btn-primary { background: var(--blue-500); color: #fff; box-shadow: 0 8px 22px rgba(11, 107, 255, .30); }
  .btn-primary:hover { background: var(--blue-600); }
  .btn-secondary { background: #fff; border-color: var(--line-strong); color: var(--ink); }
  .btn-secondary:hover { border-color: var(--blue-500); color: var(--blue-500); }
  .btn-ghost { background: var(--bg-soft); color: var(--ink); }
  .btn-ghost:hover { background: var(--info-soft); color: var(--blue-600); }
  .btn-text { background: none; color: var(--blue-500); padding: 0 var(--space-2); min-height: var(--control-h-sm); }
  .btn-text:hover { color: var(--blue-600); }
  .btn-danger { background: var(--danger); color: #fff; }
  .btn-danger:hover { background: #bf2f26; }
  .btn-danger-plain { background: #fff; border-color: var(--danger-line); color: var(--danger); }
  .btn-light { background: #fff; color: var(--blue-600); }
  .btn-outline-light { background: transparent; border-color: rgba(255,255,255,.42); color: #fff; }
  .btn-sm { min-height: var(--control-h-sm); padding: 0 var(--space-4); font-size: var(--fs-small); border-radius: var(--radius-sm); }
  .btn-block { width: 100%; }

  /* 加载中 */
  .spinner {
    width: 15px; height: 15px; border-radius: 50%; flex: none;
    border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
    animation: spin .7s linear infinite;
  }
  .btn-secondary .spinner { border-color: var(--line-strong); border-top-color: var(--blue-500); }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ====================================================================
     3. Badge 徽章 / 状态标签
     ==================================================================== */
  .badge {
    display: inline-flex; align-items: center; gap: var(--space-2);
    padding: var(--trim-2) var(--space-3); border-radius: var(--radius-pill);
    font-size: var(--fs-small); font-weight: var(--fw-bold); line-height: 1.6;
  }
  .badge svg { width: 14px; height: 14px; }
  .badge-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
  .badge-success { background: var(--success-soft); color: var(--success); }
  .badge-warning { background: var(--warning-soft); color: var(--warning); }
  .badge-danger  { background: var(--danger-soft);  color: var(--danger); }
  .badge-info    { background: var(--info-soft);    color: var(--blue-600); }
  .badge-neutral { background: var(--bg-muted);     color: var(--muted); }
  .badge-brand   { background: var(--blue-500);     color: #fff; }
  .badge-outline { background: #fff; border: 1px solid var(--line); color: var(--muted); }
  /* 文件类型微标签（特殊情况字号） */
  .tag-file {
    display: inline-block; padding: var(--trim-1) 0; width: 34px; text-align: center;
    border-radius: 5px; font-size: var(--fs-micro); font-weight: var(--fw-black);
  }
  .tag-file.pdf  { background: #fde8e2; color: #b8451d; }
  .tag-file.jpg  { background: #e4eeff; color: #1d5fc4; }
  .tag-file.xlsx { background: #dcf5e9; color: #0f7a55; }

  /* ====================================================================
     4. 输入与表单
     ==================================================================== */
  .field { display: grid; gap: var(--space-2); }
  .label { font-size: var(--fs-small); font-weight: var(--fw-bold); color: var(--ink); }
  .hint { font-size: var(--fs-small); color: var(--faint); }
  .error-text { font-size: var(--fs-small); color: var(--danger); }
  .input, .select, .textarea {
    width: 100%; min-height: var(--control-h); padding: 0 var(--space-4);
    border: 1.5px solid var(--line); border-radius: var(--radius-btn);
    background: #fff; color: var(--ink); font-size: var(--fs-body); font-family: inherit;
    transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
  }
  .textarea { padding: var(--space-3) var(--space-4); min-height: 88px; resize: vertical; line-height: 1.6; }
  .input::placeholder, .textarea::placeholder { color: var(--faint); }
  .input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--blue-500); box-shadow: var(--shadow-focus);
  }
  .input[disabled], .select[disabled] { background: var(--bg-muted); color: var(--faint); cursor: not-allowed; }
  .input.is-error { border-color: var(--danger); }
  .input.is-error:focus { box-shadow: 0 0 0 3px rgba(217, 59, 48, .12); }
  .select {
    appearance: none; padding-right: var(--space-8); cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364798f' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
  }
  .input-icon { position: relative; }
  .input-icon svg { position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--faint); pointer-events: none; }
  .input-icon .input { padding-left: calc(var(--space-3) + 18px + var(--space-2)); /* spacing-ok: 18px 为图标几何尺寸，非间距 */ }

  /* 登录 / 注册卡 */
  .auth-card {
    width: 100%; max-width: 380px; padding: var(--space-8);
    border: 1px solid var(--line); border-radius: var(--radius-xl);
    background: #fff; box-shadow: var(--shadow);
  }

  /* ====================================================================
     5. Card
     ==================================================================== */
  .card {
    padding: var(--pad-card); border: 1px solid var(--line);
    border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow);
  }
  .card-compact { padding: var(--pad-card-compact); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
  .card-title { font-size: var(--fs-title); font-weight: var(--fw-bold); letter-spacing: -0.02em; margin: 0 0 var(--space-2); }
  .card-text { color: var(--muted); font-size: var(--fs-body); margin: 0; }
  .card-icon {
    display: grid; width: 42px; height: 42px; place-items: center; margin-bottom: var(--space-3);
    border-radius: 12px; background: var(--bg-soft); border: 1px solid var(--line); font-size: 20px;
  }
  .card-icon svg { width: 21px; height: 21px; color: var(--blue-500); }
  .card-clickable { cursor: pointer; transition: border-color var(--duration) var(--ease), transform var(--duration) var(--ease); }
  .card-clickable:hover { border-color: var(--blue-400); transform: translateY(-2px); }

  /* 统计卡（后台） */
  .stat { padding: var(--pad-card-compact); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
  .stat-label { font-size: var(--fs-small); color: var(--muted); display: flex; align-items: center; gap: var(--space-2); }
  .stat-value { font-size: 28px; font-weight: var(--fw-heavy); letter-spacing: -0.04em; line-height: 1.2; margin-top: var(--space-1); }
  .stat-unit { font-size: var(--fs-small); font-weight: var(--fw-medium); color: var(--muted); margin-left: var(--space-1); }
  .stat-delta { font-size: var(--fs-small); font-weight: var(--fw-bold); }
  .stat-delta.up { color: var(--success); }
  .stat-delta.down { color: var(--danger); }

  /* ====================================================================
     6. Table
     ==================================================================== */
  .table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
  table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
  thead th {
    padding: var(--space-3) var(--space-4); text-align: left; font-weight: var(--fw-bold);
    color: var(--muted); background: var(--bg-muted); border-bottom: 1px solid var(--line); white-space: nowrap;
  }
  tbody td { padding: 0 var(--space-4); height: var(--row-h); border-bottom: 1px solid var(--line); color: var(--ink-soft); }
  tbody tr:last-child td { border-bottom: 0; }
  tbody tr:hover td { background: var(--bg-soft); }
  td.num { font-variant-numeric: tabular-nums; }
  .cell-user { display: flex; align-items: center; gap: var(--space-2); }
  .avatar {
    width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;
    background: var(--info-soft); color: var(--blue-600); font-size: var(--fs-micro); font-weight: var(--fw-bold);
  }
  .row-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }

  /* 表格手机端：卡片化 */
  @media (max-width: 700px) {
    .table-wrap { border: 0; background: transparent; }
    table, thead, tbody, tr, td, th { display: block; }
    thead { display: none; }
    tbody tr {
      margin-bottom: var(--space-3); padding: var(--space-4);
      border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
    }
    tbody td { height: auto; padding: var(--space-2) 0; border: 0; display: flex; justify-content: space-between; gap: var(--space-4); }
    tbody td::before { content: attr(data-label); color: var(--faint); font-size: var(--fs-small); flex: none; }
    tbody td:last-child { padding-top: var(--space-3); margin-top: var(--space-2); border-top: 1px dashed var(--line); }
    tbody td:last-child::before { display: none; }
    .row-actions { width: 100%; justify-content: flex-start; }
  }

  /* ====================================================================
     7. Modal 弹窗
     ==================================================================== */
  .mask { position: fixed; inset: 0; background: rgba(10, 37, 64, .42); display: grid; place-items: center; padding: var(--space-5); z-index: var(--z-modal); }
  .modal {
    width: 100%; max-width: 440px; padding: var(--space-6);
    background: #fff; border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
    position: relative;
  }
  .modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-3); }
  .modal-title { font-size: var(--fs-title); font-weight: var(--fw-bold); margin: 0; }
  .modal-close {
    width: var(--control-h-sm); height: var(--control-h-sm); border-radius: var(--radius-sm); border: 0; background: var(--bg-muted);
    color: var(--muted); cursor: pointer; display: grid; place-items: center; flex: none;
  }
  .modal-close:hover { background: var(--line); color: var(--ink); }
  .modal-body { color: var(--muted); font-size: var(--fs-body); }
  .modal-foot { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-6); }
  .modal-foot:has(.btn-danger) { gap: var(--gap-inline-loose); }

  /* ====================================================================
     8. Alert 提示条 / Toast / 空状态 / 加载
     ==================================================================== */
  .alert {
    display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4);
    border-radius: var(--radius); font-size: var(--fs-body); border: 1px solid transparent;
  }
  .alert svg { width: 18px; height: 18px; flex: none; margin-top: var(--trim-2); }
  .alert-success { background: var(--success-soft); border-color: var(--success-line); color: #0b5c45; }
  .alert-warning { background: var(--warning-soft); border-color: var(--warning-line); color: #7d5312; }
  .alert-danger  { background: var(--danger-soft);  border-color: var(--danger-line);  color: #a32b22; }
  .alert-info    { background: var(--info-soft);    border-color: var(--info-line);    color: var(--blue-700); }

  .toast {
    display: inline-flex; align-items: center; gap: var(--space-2);
    padding: var(--space-3) var(--space-4); border-radius: var(--radius-btn);
    background: var(--blue-900); color: #fff; font-size: var(--fs-small); font-weight: var(--fw-medium);
    box-shadow: var(--shadow-lg);
  }
  .toast svg { width: 16px; height: 16px; }

  .empty { padding: var(--space-10) var(--space-6); text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); background: var(--bg-soft); }
  .empty svg { width: 40px; height: 40px; color: var(--faint); }
  .empty-title { font-size: var(--fs-title); font-weight: var(--fw-bold); margin: var(--space-3) 0 var(--space-1); }
  .empty-text { color: var(--muted); font-size: var(--fs-small); margin: 0 0 var(--space-4); }

  .progress { height: 7px; border-radius: var(--radius-pill); background: var(--bg-muted); overflow: hidden; }
  .progress i { display: block; height: 100%; border-radius: var(--radius-pill); background: linear-gradient(90deg, var(--blue-600), var(--success)); transition: width var(--duration-slow) var(--ease); }

  .skeleton { background: linear-gradient(90deg, var(--bg-muted) 25%, #eef3f9 37%, var(--bg-muted) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-sm); height: 14px; }
  @keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

  /* ====================================================================
     9. 上传区 / 文件列表 / 额度条
     ==================================================================== */
  .dropzone {
    padding: var(--space-10) var(--space-6); text-align: center; cursor: pointer;
    border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg);
    background: var(--bg-soft); transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
  }
  .dropzone:hover, .dropzone.is-over { border-color: var(--blue-500); background: var(--info-soft); }
  .dropzone svg { width: 38px; height: 38px; color: var(--blue-500); }
  .dropzone-title { font-size: var(--fs-title); font-weight: var(--fw-bold); margin: var(--space-3) 0 var(--space-1); }
  .dropzone-hint { color: var(--muted); font-size: var(--fs-small); margin: 0; }

  .file-item {
    display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
    border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
  }
  .file-item + .file-item { margin-top: var(--space-2); }
  .file-name { font-family: var(--font-mono); font-size: var(--fs-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
  .file-item svg { width: 18px; height: 18px; flex: none; color: var(--faint); }
  .file-item.is-ok svg { color: var(--success); }
  .file-item.is-warn svg { color: var(--warning); }

  .quota { padding: var(--pad-card-compact); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
  .quota-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
  .quota-num { font-size: 26px; font-weight: var(--fw-heavy); letter-spacing: -0.04em; }
  .quota-num small { font-size: var(--fs-small); font-weight: var(--fw-medium); color: var(--muted); margin-left: var(--space-1); }

  /* ====================================================================
     10. Header / 后台布局
     ==================================================================== */
  .header {
    position: sticky; top: 0; z-index: var(--z-sticky); height: var(--header-h);
    background: rgba(255,255,255,.9); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line);
  }
  .header-inner { max-width: var(--max); margin: 0 auto; padding: 0 var(--space-6); height: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); }
  .nav-links { display: flex; gap: var(--space-6); font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--muted); }
  .nav-links a:hover { color: var(--blue-500); }

  .app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; background: var(--bg-soft); }
  .sidebar { background: #fff; border-right: 1px solid var(--line); padding: var(--space-4) var(--space-3); }
  .side-item {
    display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-3);
    border-radius: var(--radius-btn); color: var(--muted); font-size: var(--fs-small); font-weight: var(--fw-medium);
  }
  .side-item svg { width: 18px; height: 18px; }
  .side-item:hover { background: var(--bg-soft); color: var(--ink); }
  .side-item.active { background: var(--info-soft); color: var(--blue-600); font-weight: var(--fw-bold); }
  .side-group { font-size: var(--fs-micro); font-weight: var(--fw-black); color: var(--faint); letter-spacing: var(--ls-wide); padding: var(--space-4) var(--space-3) var(--space-2); text-transform: uppercase; }
  .app-main { padding: var(--space-6); }
  .app-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); }
  .page-title { font-size: 21px; font-weight: var(--fw-heavy); letter-spacing: var(--ls-heading); margin: 0; }
  @media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }
  }

  /* ====================================================================
     11. 布局节奏 Layout Rhythm（阶段 2a：仅定义，尚未挂载）
     ==================================================================== */
  .stack-y > :not(.hidden):not([hidden]):not(input[type="hidden"]),
  .view-stack > :not(.hidden):not([hidden]):not(input[type="hidden"]) { margin-block: 0; }
  .stack-y > :not(.hidden):not([hidden]):not(input[type="hidden"]) ~ :not(.hidden):not([hidden]):not(input[type="hidden"]) { margin-top: var(--stack-inner); }
  .view-stack > :not(.hidden):not([hidden]):not(input[type="hidden"]) ~ :not(.hidden):not([hidden]):not(input[type="hidden"]) { margin-top: var(--section-gap-app); }
  .card-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap-inline);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--line);
  }
  .view-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--gap-inline);
    margin-top: var(--space-4);
  }
  .view-actions:not(:has(> :not(.hidden):not([hidden]))) { display: none; }
  .card-foot-note { margin: 0; color: var(--muted); font-size: var(--fs-small); }
  .pager { display: inline-flex; flex-wrap: wrap; gap: var(--gap-inline-tight); }
/* >>> ui-foundation:start */
/* Behavior-only enhancements. Classic .btn/.card remain the visual source. */
.zyp-ui .zyp-viewer { width: min(960px, calc(100vw - var(--space-8))); max-height: calc(100dvh - var(--space-8)); padding: var(--space-5); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--bg); overflow-y: auto; }
.zyp-ui .zyp-viewer::backdrop { background: color-mix(in srgb, var(--ink) 55%, transparent); }
.zyp-ui .viewer-head { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-inline); }
.zyp-ui .viewer-head h2 { margin: 0; font-size: var(--fs-title); }
.zyp-ui .viewer-stage { display: grid; min-height: 180px; place-items: center; padding-top: var(--space-4); }
.zyp-ui .viewer-stage img { display: block; max-width: 100%; max-height: 65dvh; object-fit: contain; }
.zyp-ui .zyp-table-hint { margin: var(--space-2) 0 0; color: var(--muted); font-size: var(--fs-small); }
.zyp-ui .btn[aria-busy="true"] { cursor: wait; }
.zyp-ui .showcase-page { width: min(1100px, calc(100% - var(--space-8))); margin: var(--space-8) auto; }
.zyp-ui .control-group { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-inline); }
.zyp-ui .control-group .input, .zyp-ui .control-group .select { width: auto; min-width: 0; }
.zyp-ui .controls-compact .input, .zyp-ui .controls-compact .select, .zyp-ui .controls-compact .btn { min-height: var(--control-h-sm); }
.zyp-ui .cloud-filters [data-count] { font-variant-numeric: tabular-nums; }
.zyp-ui [data-zyp-state][hidden], .zyp-ui .zyp-table-hint[hidden], .zyp-ui [data-zyp-viewer-error][hidden] { display: none; }
/* <<< ui-foundation:end */
/* <<< design-source-sync:end */
