/* 仅管理后台使用；原生字段仍负责表单值、校验和联动。 */
:root {
  --control-border: #c5d3e2;
  --control-hover: #7caee0;
  --control-focus: #0878e8;
  --control-ring: #0878e81a;
  --control-text: #253b52;
  --control-muted: #63778d;
}
:is(#appView, #editor) :where(input:not([type=checkbox]):not([type=radio]), select, textarea) {
  min-height: 40px;
  max-width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background-color: #fff;
  color: var(--control-text);
  font-family: var(--ui-font);
  font-size: 13px;
  line-height: 20px;
  transition: border-color .16s, box-shadow .16s;
  color-scheme: light;
}
:is(#appView, #editor) :is(input, textarea)::placeholder { color: var(--control-muted); opacity: 1; }
:is(#appView, #editor) :is(input, select, textarea):hover:not(:disabled) { border-color: var(--control-hover); }
:is(#appView, #editor) :is(input, select, textarea):focus {
  border-color: var(--control-focus);
  outline: 2px solid var(--control-focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--control-ring);
}
:is(#appView, #editor) :is(input, select, textarea):disabled {
  background-color: #f1f5f9;
  color: #6a7a8b;
  border-color: #dbe3ec;
  cursor: not-allowed;
}
:is(#appView, #editor) :is(input, select, textarea)[aria-invalid=true] { border-color: #bf3e4c; }
:is(#appView, #editor) input[type=search] {
  appearance: none;
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2363778d' stroke-width='1.7' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='m16 16 4.5 4.5'/%3E%3C/svg%3E");
  background-size: 17px;
  background-repeat: no-repeat;
  background-position: 12px center;
}
:is(#appView, #editor) input[type=search]::-webkit-search-cancel-button { cursor: pointer; }
:is(#appView, #editor) select {
  appearance: none;
  padding-right: 34px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2363778d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-size: 18px;
  background-position: right 10px center;
  background-repeat: no-repeat;
}
/* 使用浏览器自己的选择行为，统一选项面板，不复制一套选中状态。 */
@supports (appearance: base-select) {
  :is(#appView, #editor, .console-calendar) select,
  :is(#appView, #editor, .console-calendar) select::picker(select) { appearance: base-select; }
  :is(#appView, #editor, .console-calendar) select { background-image: none; padding-right: 12px; align-items: center; gap: 10px; }
  :is(#appView, #editor, .console-calendar) select::picker-icon {
    content: ''; width: 16px; height: 16px; flex-shrink: 0;
    background: center / 16px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2363778d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  }
  :is(#appView, #editor, .console-calendar) select:open { border-color: var(--control-focus); box-shadow: 0 0 0 3px var(--control-ring); }
  :is(#appView, #editor, .console-calendar) select::picker(select) {
    margin-block: 6px;
    padding: 6px;
    min-width: anchor-size(width);
    max-width: min(480px, calc(100vw - 24px));
    max-height: min(320px, 60dvh);
    overflow: auto;
    border: 1px solid #dbe6f1;
    border-radius: 10px;
    box-shadow: 0 10px 32px #284d7024, 0 2px 8px #284d700a;
    background: #fff;
    color: var(--control-text);
    font: 13px/1.5 var(--ui-font);
  }
  :is(#appView, #editor, .console-calendar) option {
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 6px;
    white-space: normal;
    overflow-wrap: anywhere;
    cursor: pointer;
    gap: 12px;
  }
  :is(#appView, #editor, .console-calendar) option:hover,
  :is(#appView, #editor, .console-calendar) option:focus { background: #f0f7ff; outline: none; }
  :is(#appView, #editor, .console-calendar) option:checked { background: #e7f2ff; color: #0869ce; font-weight: 500; }
  :is(#appView, #editor, .console-calendar) option::checkmark { order: 1; margin-left: auto; color: #0878e8; }
  :is(#appView, #editor, .console-calendar) option:disabled { color: #8290a0; cursor: not-allowed; }
}
.filters > label, .finance-filter > label, .customer-search label { min-width: 0; gap: 7px; }
.customer-search label { display: grid; }
.filters > :is(.primary, .secondary), .customer-filters > button, .finance-filter .actions > button, .customer-search > button { min-height: 40px; height: auto; border-radius: 8px; }
.console-date-field { position: relative; display: block; min-width: 0; }
#dateFilter > label { min-width: 155px; }
:is(#appView, #editor) .console-date-field > input { width: 100%; min-width: 0; padding-right: 42px; font-family: var(--number-font); }
.console-date-field > input::-webkit-calendar-picker-indicator { display: none; }
.console-date-field > input::-webkit-datetime-edit { padding: 0; }
.console-date-button {
  position: absolute; right: 3px; top: 3px; bottom: 3px;
  display: grid; place-items: center; width: 34px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--control-muted);
}
.console-date-button svg { width: 18px; height: 18px; }
.console-date-button:hover, .console-date-button[aria-expanded=true] { background: #eaf4ff; color: #0878e8; }
.console-date-button:disabled { cursor: not-allowed; }
.console-calendar {
  position: fixed; inset: auto; margin: 0; padding: 16px;
  width: 320px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow: auto;
  border: 1px solid #dbe6f1; border-radius: 12px;
  box-shadow: 0 12px 40px #284d7029; background: #fff;
  font: 13px/1.5 var(--ui-font); color: var(--control-text); color-scheme: light;
}
.console-calendar button { font: inherit; min-height: 32px; border: 0; border-radius: 6px; color: inherit; background: transparent; }
.console-calendar button:hover { background: #edf5ff; color: #0869ce; }
.console-calendar :is(button, input, select):focus-visible { outline: 2px solid #0878e8; outline-offset: 2px; }
.console-calendar button:disabled { cursor: not-allowed; opacity: .4; }
.calendar-caption { font-size: 12px; color: var(--control-muted); margin-bottom: 12px; }
.calendar-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.calendar-nav > button { width: 30px; padding: 6px; flex-shrink: 0; }
.calendar-nav svg { display: block; width: 18px; height: 18px; }
:is(body, #editor) .console-calendar :is(input, select) { min-height: 34px; padding: 5px 8px; font: inherit; border: 1px solid var(--control-border); border-radius: 6px; background-color: #fff; color: var(--control-text); }
.calendar-nav input { width: 82px; }
.calendar-nav select { width: 86px; }
.calendar-weekdays, .calendar-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; gap: 3px; }
.calendar-weekdays { color: var(--control-muted); font-size: 12px; margin-bottom: 8px; }
.calendar-days button { padding: 0; height: 34px; font-family: var(--number-font); }
.calendar-days .outside { color: #768699; }
.calendar-days [aria-current=date] { box-shadow: inset 0 0 0 1px #84b9ed; color: #0869ce; }
.calendar-days [aria-pressed=true] { background: #0878e8; color: #fff; box-shadow: none; }
.calendar-time { display: flex; align-items: center; gap: 8px; border-top: 1px solid #edf2f7; padding-top: 12px; margin-top: 12px; }
.calendar-time > span:first-child { margin-right: auto; color: var(--control-muted); }
.calendar-time input { width: 58px; font-family: var(--number-font); }
.calendar-message { margin-top: 8px; color: #ae3544; font-size: 12px; }
.calendar-message:empty { display: none; }
.calendar-footer { display: flex; gap: 6px; border-top: 1px solid #edf2f7; padding-top: 12px; margin-top: 12px; }
.calendar-footer button { padding: 5px 10px; color: #0869ce; }
.calendar-footer [data-calendar=cancel] { margin-left: auto; color: var(--control-muted); }
.calendar-footer [data-calendar=apply] { background: #0878e8; color: #fff; }
.calendar-footer [data-calendar=apply]:hover { background: #0069d2; }
@media (max-width: 760px) {
  #dateFilter { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  #dateFilter > label { grid-column: span 1; }
  #dateFilter > button { width: 100%; }
  .dashboard-filters > .filters { width: 100%; }
}
@media (max-width: 420px) {
  #dateFilter > label { grid-column: 1 / -1; }
}
