/* ==========================================================================
   表单页样式层｜参考图 2「上传食物」
   --------------------------------------------------------------------------
   负责：一体化诊台（consult）、填写问诊（inquiryForm）与全部录入弹窗的表单区。
   语言：纯白画布、分组标题「（必填）」、左标签右值、行间一条发丝线、
   浅灰占位、辅助小字在标签下方、右端浅灰方块图标、
   绿色半胶囊单位切换、唯一强调色薄荷绿用于「完成 / 提交」。
   边界：页面壳（顶栏之外的导航、列表、Tabbar）仍由 upgrade.css 管；
   本层只覆盖录入区域。打印隔离：全部顶层规则均为 @media screen。
   ========================================================================== */
@media screen {

  /* ======================================================================
     1. 画布：纯白，去掉壳层的浅蓝雾与卡片浮层
     ====================================================================== */
  body[data-mode="form"] {
    background: #fff;
    background-image: none;
  }
  body[data-mode="form"] .app-shell {
    background: #fff;
    border-radius: 0;
    box-shadow: none;
  }
  body[data-mode="form"] .app-view { background: #fff; }
  body[data-mode="form"] .m-page { padding: 0 20px 28px; }
  /* 参考图 2 是全屏表单页：底部导航让位于返回箭头与「完成」 */
  body[data-mode="form"] .app-tabbar { display: none !important; }
  body[data-mode="form"] .app-view.is-tabbed { padding-bottom: 20px; }

  /* ======================================================================
     2. 顶栏：白底、居中近黑加粗标题、深灰返回、绿色「完成」
     ====================================================================== */
  body[data-mode="form"] .app-header {
    background: transparent;
    color: var(--form-label);
    border-bottom: 0;
    box-shadow: none;
    border-radius: 0;
    padding-left: 14px;
    padding-right: 14px;
  }
  body[data-mode="form"] .app-header .hd-title {
    color: #22272f;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0;
  }
  body[data-mode="form"] .app-header .hd-sub { color: var(--form-hint); }
  body[data-mode="form"] .app-header .hd-back {
    background: transparent;
    color: #2f3540;
    border-radius: var(--r-sm);
  }
  body[data-mode="form"] .app-header .hd-back:active { background: var(--form-unit-bg); }
  body[data-mode="form"] .app-header .hd-seal {
    background: var(--color-accent-soft);
    border-color: var(--color-accent-line);
    color: var(--form-green-strong);
    font-family: var(--font-body);
  }
  /* 参考图 2 右上角绿色「完成」：点击转交底部主提交按钮，复用全部校验逻辑 */
  .hd-done {
    flex: 0 0 auto;
    min-width: 46px; min-height: 44px;
    padding: 0 4px 0 8px;
    color: var(--form-green-strong);
    font-size: 16px; font-weight: 600;
    letter-spacing: .01em;
  }
  .hd-done:active { opacity: .6; }

  /* ======================================================================
     3. 分组标题：加粗近黑 + 「（必填）/（选填）」，无边框无底色
     ====================================================================== */
  body[data-mode="form"] .section,
  body[data-mode="form"] .section .section,
  body[data-mode="form"] .m-form.m-card {
    margin: 0;
    padding: 0;
    background: #fff;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  body[data-mode="form"] .section-head {
    display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 7px;
    padding: 30px 20px 12px;
    background: transparent;
    border: 0;
  }
  body[data-mode="form"] .section-index {
    display: none;
  }
  body[data-mode="form"] .section-title {
    flex: 0 0 auto;
    color: #22272f;
    font-family: var(--font-body);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0;
  }
  .req-note {
    flex: 0 0 auto;
    color: #6b7480;
    font-size: 13px;
    font-weight: 400;
  }
  body[data-mode="form"] .section-note {
    flex: 1 1 100%;
    color: var(--form-hint);
    font-size: 11px;
    font-weight: 400;
  }
  body[data-mode="form"] .section-body { padding: 0 20px 6px; }
  body[data-mode="form"] .section-body.tight { padding: 0 20px 6px; }
  body[data-mode="form"] .section-body.stack { gap: 0; }
  body[data-mode="form"] .section-foot {
    background: #fff; border-top: 1px solid var(--form-line);
  }

  /* 页面内表单（填写问诊）的分组标题 */
  body[data-mode="form"] .m-section-title { margin: 28px 0 10px; }
  body[data-mode="form"] .m-section-title::before { display: none; }
  body[data-mode="form"] .m-section-title h2 {
    color: #22272f; font-family: var(--font-body); font-size: 17px; font-weight: 700;
  }
  body[data-mode="form"] .m-section-title .sub { color: var(--form-hint); }
  body[data-mode="form"] .m-card { border: 0; box-shadow: none; border-radius: 0; background: #fff; }
  body[data-mode="form"] .m-form { gap: 0; }

  /* ======================================================================
     4. 表单行：左标签 / 右值 / 一条发丝线
     ====================================================================== */
  /* 只作用于「表单行容器」的直接字段，避免误伤栅格内的紧凑字段 */
  body[data-mode="form"] .section-body > .field:not(:has(.grid-2, .grid-3, .stack, .choice-row, .textarea, .dx-item, .m-chip-row, .segment, .rx-pick)),
  .m-form > .field:not(:has(.grid-2, .grid-3, .stack, .choice-row, .textarea, .dx-item, .m-chip-row, .segment, .rx-pick)) {
    display: grid;
    grid-template-columns: minmax(88px, 33%) minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 10px;
    min-height: var(--form-row-h);
    padding: 8px 0;
    border-bottom: 1px solid var(--form-line);
    background: transparent;
  }

  /* 复杂字段（多行文本、多控件栅格、诊断、标签组）：纵向排布，仍带发丝线 */
  body[data-mode="form"] .section-body > .field,
  .m-form > .field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 12px 0 14px;
    border-bottom: 1px solid var(--form-line);
    background: transparent;
  }

  /* 栅格 / 处方行内的紧凑字段：标签在上、值在下 */
  body[data-mode="form"] .grid-2 > .field,
  body[data-mode="form"] .grid-3 > .field,
  body[data-mode="form"] .rx-row .field,
  .m-form .grid-2 > .field,
  .m-form .grid-3 > .field,
  .m-form .m-rx-item .field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    min-height: 0;
    padding: 8px 0;
    border-bottom: 1px solid var(--form-line);
    background: transparent;
  }

  /* 标签：15px 近黑；辅助小字落在标签下方（参考图 2「扫描包装上的条形码」） */
  body[data-mode="form"] .section-body > .field > .field-label,
  .m-form > .field > .field-label {
    grid-column: 1;
    grid-row: 1;
    color: var(--form-label);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.45;
  }
  body[data-mode="form"] .section-body > .field > .field-hint,
  .m-form > .field > .field-hint {
    grid-column: 1;
    grid-row: 2;
    color: var(--form-hint);
    font-size: 11px;
    line-height: 1.4;
  }
  body[data-mode="form"] .grid-2 > .field > .field-label,
  body[data-mode="form"] .grid-3 > .field > .field-label,
  body[data-mode="form"] .rx-row .field > .field-label,
  .m-form .grid-2 > .field > .field-label,
  .m-form .m-rx-item .field > .field-label {
    color: var(--form-hint);
    font-size: 11px;
    font-weight: 500;
  }
  .field-label .req { color: var(--form-req); font-weight: 700; }

  /* ======================================================================
     5. 输入控件：无边框、透明底、右对齐、浅灰占位
     ====================================================================== */
  body[data-mode="form"] .input,
  body[data-mode="form"] .select,
  body[data-mode="form"] .textarea,
  .m-form .input,
  .m-form .select,
  .m-form .textarea {
    width: 100%;
    height: auto; min-height: 44px;
    padding: 0 14px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    color: var(--form-value);
    font-size: 15px;
    text-align: right;
    text-align-last: right;
  }
  body[data-mode="form"] .input::placeholder,
  body[data-mode="form"] .textarea::placeholder,
  .m-form .input::placeholder,
  .m-form .textarea::placeholder { color: var(--form-placeholder); }
  body[data-mode="form"] .select,
  .m-form .select { padding-right: 24px; background-image: none; }
  body[data-mode="form"] .input:focus,
  body[data-mode="form"] .select:focus,
  body[data-mode="form"] .textarea:focus,
  .m-form .input:focus,
  .m-form .select:focus,
  .m-form .textarea:focus {
    background: transparent;
    box-shadow: inset 0 -2px 0 rgba(47, 181, 115, .4);
    outline: none;
  }
  body[data-mode="form"] .input:disabled,
  body[data-mode="form"] .input[readonly],
  body[data-mode="form"] .select:disabled,
  .m-form .input:disabled,
  .m-form .input[readonly],
  .m-form .select:disabled {
    background: transparent;
    color: var(--form-hint);
    opacity: 1;
  }
  /* 多行文本域：左对齐，容器保留一条底线 */
  body[data-mode="form"] .textarea,
  .m-form .textarea {
    text-align: left;
    text-align-last: left;
    min-height: 76px;
    padding: 8px 0;
    line-height: 1.7;
    resize: vertical;
  }
  /* 右列占位：field-unit 包裹输入与单位后缀 */
  body[data-mode="form"] .section-body > .field > .field-unit,
  body[data-mode="form"] .section-body > .field > .input,
  body[data-mode="form"] .section-body > .field > .select,
  body[data-mode="form"] .section-body > .field > .m-select-field,
  .m-form > .field > .field-unit,
  .m-form > .field > .input,
  .m-form > .field > .select,
  .m-form > .field > .m-select-field {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
  body[data-mode="form"] .field-unit .unit,
  .m-form .field-unit .unit {
    right: 3px;
    color: var(--form-hint);
    font-size: 13px;
  }
  body[data-mode="form"] .field-unit .input { padding-right: 38px; }
  /* 栅格内的紧凑输入左对齐，避免窄列文字被挤到边缘 */
  body[data-mode="form"] .grid-2 .input,
  body[data-mode="form"] .grid-2 .select,
  body[data-mode="form"] .rx-row .input,
  body[data-mode="form"] .rx-row .select,
  .m-form .grid-2 .input,
  .m-form .grid-2 .select {
    min-height: 36px; height: auto; line-height: 1.5;
    font-size: 14px;
    text-align: left;
    text-align-last: left;
  }

  /* ======================================================================
     6. 单位切换：参考图 2 的「ml | g」半胶囊（白描边 + 绿色选中半边）
     ====================================================================== */
  body[data-mode="form"] .segment,
  .m-form .segment {
    display: inline-flex;
    gap: 0;
    width: auto;
    padding: 0;
    background: #fff;
    border: 1px solid #dfe4ea;
    border-radius: 6px;
    overflow: hidden;
  }
  body[data-mode="form"] .segment button,
  .m-form .segment button {
    min-height: 34px;
    padding: 0 13px;
    border-right: 1px solid #dfe4ea;
    border-radius: 0;
    color: #8b939e;
    background: #fff;
    font-size: 13px;
    font-weight: 500;
    box-shadow: none;
  }
  body[data-mode="form"] .segment button:last-child,
  .m-form .segment button:last-child { border-right: 0; }
  body[data-mode="form"] .segment button.is-active,
  .m-form .segment button.is-active {
    background: var(--form-green);
    color: #fff;
    font-weight: 600;
  }
  /* 处方 Tab（中药饮片 / 西药）同款半胶囊，但撑满一行 */
  body[data-mode="form"] .rx-tabs { margin: 0 20px 4px; padding-top: 14px; }
  body[data-mode="form"] .rx-tabs .segment { display: flex; width: 100%; }
  body[data-mode="form"] .rx-tabs .segment button { flex: 1 1 0; min-height: 38px; }

  /* ======================================================================
     7. 右端浅灰方块：呼应参考图 2 的相机上传按钮
     ====================================================================== */
  body[data-mode="form"] .m-select-field,
  .m-form .m-select-field {
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    background: transparent;
    border: 0;
    border-radius: 0;
    color: var(--form-placeholder);
    font-size: 15px;
  }
  body[data-mode="form"] .m-select-field.has-value,
  .m-form .m-select-field.has-value { color: var(--form-value); }
  body[data-mode="form"] .m-select-field svg,
  .m-form .m-select-field svg {
    width: 30px; height: 30px; flex: 0 0 30px;
    padding: 7px; box-sizing: border-box;
    background: var(--form-unit-bg);
    border-radius: 8px;
    color: #9aa4b2;
  }
  body[data-mode="form"] .rx-pick {
    background: var(--form-unit-bg);
    border: 0;
    border-radius: 8px;
    color: var(--form-hint);
    min-height: 44px;
  }
  body[data-mode="form"] .rx-pick svg {
    width: 26px; height: 26px; padding: 5px; box-sizing: border-box;
    background: #fff; border-radius: 7px; color: #9aa4b2;
  }

  /* 药品类型：西药 / 中药饮片 分段控件加大间距 */
  body[data-mode="form"] #rxType,
  .m-form #rxType {
    gap: 12px;
    padding: 4px;
  }
  body[data-mode="form"] #rxType button,
  .m-form #rxType button {
    min-height: 42px;
    font-size: 14px;
  }

  /* ======================================================================
     8. 单选 / 开关 / 诊断条目：去掉蓝底卡片，只留发丝线
     ====================================================================== */
  body[data-mode="form"] .choice,
  .m-form .choice {
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid #dfe4ea;
    border-radius: var(--r-pill);
    background: #fff;
    color: var(--form-label);
    font-size: 13px;
  }
  body[data-mode="form"] .choice:has(input:checked),
  .m-form .choice:has(input:checked) {
    background: var(--color-accent-soft);
    border-color: var(--color-accent-line);
    color: var(--form-green-strong);
  }
  body[data-mode="form"] .choice input,
  .m-form .choice input { accent-color: var(--form-green); }

  body[data-mode="form"] .switch-row {
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--form-line);
    border-radius: 0;
    padding: 12px 0;
  }
  body[data-mode="form"] .switch-row .sw-title { color: var(--form-label); font-weight: 600; }
  body[data-mode="form"] .switch input:checked + .track { background: var(--form-green); }

  body[data-mode="form"] .dx-item {
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--form-line);
    border-radius: 0;
    padding: 10px 0;
    margin: 0;
  }
  body[data-mode="form"] .dx-item .dx-code {
    background: var(--form-unit-bg);
    border: 0;
    color: var(--form-hint);
  }
  body[data-mode="form"] .dx-item .dx-name { color: var(--form-label); }
  body[data-mode="form"] .dx-item .dx-del { color: var(--form-req); }

  /* ======================================================================
     9. 患者只读信息卡 / 签名 / 提示 / 处方行：全部化为白底发丝线
     ====================================================================== */
  body[data-mode="form"] .his-panel {
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
  }
  body[data-mode="form"] .his-panel-head {
    padding: 16px 20px 12px;
    background: #fff;
    border: 0;
    color: var(--form-label);
  }
  body[data-mode="form"] .his-panel-head .his-name { font-family: var(--font-body); font-size: 16px; }
  body[data-mode="form"] .his-panel-head .his-mark {
    border-color: var(--form-line); background: var(--form-unit-bg); color: var(--form-hint);
  }
  body[data-mode="form"] .his-cell { border-bottom: 1px solid var(--form-line); padding: 8px 20px; }
  body[data-mode="form"] .his-cell .k { color: var(--form-hint); }
  body[data-mode="form"] .his-cell .v { color: var(--form-value); font-weight: 600; }
  body[data-mode="form"] .his-cell .v.alert { color: var(--form-req); }
  body[data-mode="form"] .his-foot { padding: 10px 20px; border-top: 1px solid var(--form-line); }
  body[data-mode="form"] .his-auth { padding: 8px 20px; border-bottom: 1px solid var(--form-line); }

  body[data-mode="form"] .rx-sign {
    margin: 0 20px;
    padding: 12px 0;
    background: #fff;
    border: 0;
    border-bottom: 1px solid var(--form-line);
    border-radius: 0;
    box-shadow: none;
  }
  body[data-mode="form"] .rx-status { margin: 0 20px; }
  body[data-mode="form"] .rx-status .notice { padding: 8px 0; background: transparent; }
  body[data-mode="form"] .notice { border-radius: 8px; }

  body[data-mode="form"] .rx-row {
    margin: 0;
    border: 0;
    border-bottom: 1px solid var(--form-line);
    border-radius: 0;
    box-shadow: none;
    background: #fff;
  }
  body[data-mode="form"] .rx-row.has-block { border-bottom-color: var(--color-block-line); }
  body[data-mode="form"] .rx-row.has-warn { border-bottom-color: var(--color-warn-line); }
  body[data-mode="form"] .rx-row-head {
    padding: 12px 0;
    background: #fff;
    border-bottom: 1px solid var(--form-line);
  }
  body[data-mode="form"] .rx-row-num {
    background: var(--form-unit-bg);
    color: var(--form-hint);
    border-radius: 6px;
  }
  body[data-mode="form"] .rx-row-name { font-family: var(--font-body); color: var(--form-label); }
  body[data-mode="form"] .rx-row-body { padding: 0 0 10px; }
  body[data-mode="form"] .rx-row-body .rx-pick { margin-bottom: 10px; }
  body[data-mode="form"] .rx-row-divider { background: var(--form-line); height: 1px; }
  body[data-mode="form"] .rx-row-foot,
  body[data-mode="form"] .rx-total {
    padding: 11px 0;
    background: #fff;
    border-top: 1px solid var(--form-line);
    border-bottom: 0;
  }
  body[data-mode="form"] .rx-row-foot .amount { color: var(--color-price); }
  body[data-mode="form"] .rx-total .val { color: var(--color-price); }
  body[data-mode="form"] .rx-row-issue { border-top: 0; padding: 0; }
  body[data-mode="form"] .rx-quant {
    background: #fff;
    border: 1px dashed var(--form-line);
    border-radius: 8px;
    margin: 8px 0 12px;
  }
  body[data-mode="form"] .rx-auto-tag.is-on {
    background: var(--color-accent-soft);
    color: var(--form-green-strong);
  }

  /* 新增一行按钮：绿色描边，弱化但可点 */
  body[data-mode="form"] .btn-soft {
    background: #fff;
    border: 1px solid var(--color-accent-line);
    border-radius: 10px;
    color: var(--form-green-strong);
  }

  /* ======================================================================
     10. 表单内的主按钮统一为绿色：避免壳层亮蓝与表单绿形成双强调
     ====================================================================== */
  body[data-mode="form"] .btn-primary,
  .m-form .btn-primary,
  .overlay .modal:has(.m-form) .modal-foot .btn-primary {
    background: var(--form-green);
    border-color: var(--form-green);
    color: #fff;
    box-shadow: 0 6px 16px rgba(15, 131, 84, .22);
  }
  body[data-mode="form"] .btn-primary:hover,
  .m-form .btn-primary:hover,
  .overlay .modal:has(.m-form) .modal-foot .btn-primary:hover {
    background: var(--form-green-strong);
  }
  body[data-mode="form"] .preview-toolbar .btn {
    background: #fff;
    border-color: #dfe4ea;
    color: var(--form-label);
  }
  body[data-mode="form"] .his-foot .btn {
    background: transparent;
    border-color: transparent;
    color: var(--form-green-strong);
    box-shadow: none;
  }

  /* ======================================================================
     11. 底部固定操作栏：白底 + 绿色「完成 / 提交」
     ====================================================================== */
  body[data-mode="form"] .app-actionbar {
    background: rgba(255, 255, 255, .98);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-top: 1px solid var(--form-line);
    box-shadow: none;
  }
  body[data-mode="form"] .app-actionbar .btn {
    border: 0;
    background: transparent;
    color: var(--form-label);
    box-shadow: none;
    font-size: 11px;
  }
  body[data-mode="form"] .app-actionbar .btn-accent {
    background: var(--form-green);
    border-radius: 10px;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 6px 16px rgba(47, 181, 115, .24);
  }
  body[data-mode="form"] .app-actionbar .btn-accent:hover { background: var(--form-green-strong); }

  /* 表单页不参与壳层的错峰入场，避免录入时文字闪动 */
  body[data-mode="form"] .m-page > * { animation: none !important; }
}

/* ========================================================================
   宽屏：表单页保持纯白，不套手机画布的蓝色圆角阴影
   ======================================================================== */
@media screen and (min-width: 700px) {
  body[data-mode="form"] .app-shell {
    margin: 0 auto;
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }
  body[data-mode="form"] .app-tabbar { border-radius: 0; }
}

/* ========================================================================
   窄屏：分组标题与行的左右留白收紧
   ======================================================================== */
@media screen and (max-width: 360px) {
  body[data-mode="form"] .m-page { padding-left: 14px; padding-right: 14px; }
  body[data-mode="form"] .section-head { padding-left: 14px; padding-right: 14px; }
  body[data-mode="form"] .section-body,
  body[data-mode="form"] .section-body.tight { padding-left: 14px; padding-right: 14px; }
  body[data-mode="form"] .rx-tabs,
  body[data-mode="form"] .rx-status,
  body[data-mode="form"] .rx-sign { margin-left: 14px; margin-right: 14px; }
}

/* 表单页顶栏沿用全站 h5-bg.png：背景透明以透出 shell 底图，颜色由 ui-v3.css 统一控制 */
