:root {
  --bg1: #d9e7ff;
  --bg2: #eef4ff;
  --bg3: #f7f9fc;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --success: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --line: rgba(148, 163, 184, 0.32);
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --row-h: 48px;
  --radius: 14px;
}

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

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 12%, rgba(37, 99, 235, 0.16), transparent 28%),
    radial-gradient(circle at 90% 6%, rgba(14, 165, 233, 0.12), transparent 24%),
    linear-gradient(160deg, var(--bg1), var(--bg2) 42%, var(--bg3));
}

.hidden { display: none !important; }

html.modal-open,
html.modal-open body {
  overflow: hidden !important;
  overscroll-behavior: none;
}

.glass-panel,
.glass-card,
.glass-modal {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow);
}

.glass-card, .glass-modal { background: var(--glass-strong); }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
}

.login-card h1 { font-size: 1.45rem; margin-bottom: 8px; }
.login-sub, .login-tip, .hint, .subtitle { color: var(--muted); font-size: 0.88rem; }
.login-sub { margin-bottom: 18px; }
.login-tip { margin-top: 14px; }
.error-text { color: var(--danger); font-size: 0.86rem; margin-bottom: 10px; text-align: center; }
.login-card label { text-align: left; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.84rem;
  margin-bottom: 12px;
  color: #334155;
}

input, select, textarea, .btn { font: inherit; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
}

textarea { resize: vertical; }

.app {
  max-width: 1480px;
  margin: 0 auto;
  padding: 16px;
}

.header, .period-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.header, .period-bar {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.header h1 { font-size: 1.28rem; }

.user-box, .period-tabs, .pager-left, .pager-right, .inline-form, .modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.user-box span, .period-meta { color: var(--muted); font-size: 0.84rem; }
.period-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.inline-label { display: flex; flex-direction: row; align-items: center; gap: 8px; margin: 0; }

.chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.78rem;
  color: #334155;
  white-space: nowrap;
}

.chip:hover { border-color: #93c5fd; color: var(--primary); }
.chip.active {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border-color: transparent;
  color: #fff;
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.stat-card { border-radius: 12px; padding: 10px 12px; text-align: center; }
.stat-label { font-size: 0.72rem; color: var(--muted); }
.stat-value { font-size: 1.05rem; font-weight: 700; margin-top: 2px; }
.stat-value.success { color: var(--success); }
.stat-value.warn { color: var(--warn); }
.stat-value.danger { color: var(--danger); }

/* 强制筛选栏单行 */
.filter-bar {
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 8px;
  overflow: visible;
  border-radius: var(--radius);
  padding: 10px 12px 12px;
  margin-bottom: 10px;
  white-space: nowrap;
}

.filter-tabs {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 6px;
  flex: 0 0 auto;
}

.search-wrap {
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 280px;
  max-width: 520px;
}

.search-wrap select {
  width: 108px;
  flex: 0 0 auto;
  font-size: 0.8rem;
  padding: 6px 8px;
  border-radius: 10px;
  height: 34px;
  box-sizing: border-box;
}

.search-input-box {
  position: relative;
  flex: 1 1 auto;
  min-width: 160px;
}

.search-wrap input,
.search-input-box input {
  width: 100%;
  min-width: 0;
  font-size: 0.86rem;
  padding: 6px 34px 6px 12px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid #dbe3ef;
  background: #fff;
  box-sizing: border-box;
}

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 999px;
  background: #e2e8f0;
  color: #64748b;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.search-clear:hover {
  background: #cbd5e1;
  color: #334155;
}

.search-wrap .btn {
  flex: 0 0 auto;
  height: 34px;
  min-height: 34px;
  border-radius: 10px;
  padding: 0 14px;
  font-size: 0.78rem;
  font-weight: 600;
  box-sizing: border-box;
}

.orders-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: calc(var(--row-h) * 10);
  color: #94a3b8;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  user-select: none;
}

.filter-actions {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: auto;
  align-items: center;
  overflow: visible;
  padding-top: 6px;
  padding-right: 4px;
}

/* 三个操作按钮视觉同高同宽 */
.filter-actions .btn {
  width: 132px;
  min-width: 132px;
  max-width: 132px;
  height: 34px;
  min-height: 34px;
  padding: 0 8px;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: 10px;
  border-width: 1px;
  border-style: solid;
  box-sizing: border-box;
  line-height: 1;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  transform: none !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-actions .btn-system-alert {
  overflow: visible;
}

.filter-actions .btn:hover {
  transform: none !important;
}

.btn-system-alert {
  position: relative;
  background: #ef4444 !important;
  color: #fff !important;
  border-color: #ef4444 !important;
  box-shadow: none !important;
}

.filter-actions .btn-primary {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #2563eb !important;
}

.filter-actions .btn-ok {
  background: #dcfce7 !important;
  color: #047857 !important;
  border-color: #86efac !important;
}

.sys-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fbbf24;
  color: #7c2d12;
  font-size: 0.68rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  line-height: 1;
  z-index: 5;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}

.sys-badge.hidden { display: none !important; }

.btn-soft {
  background: #eef2ff;
  color: #2563eb;
  border: 1px solid #c7d2fe;
}

.btn-warn {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.btn-ok {
  background: #dcfce7;
  color: #047857;
  border: 1px solid #86efac;
}

.notice-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0 28px 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.tag-unread { background: #fee2e2; color: #dc2626; }
.tag-restocked { background: #dcfce7; color: #059669; }
.tag-muted { background: #dbeafe; color: #2563eb; }
.tag-done { background: #fef3c7; color: #d97706; }

.modal-notice {
  max-width: 640px;
}

.notice-list {
  height: 360px;
  max-height: 360px;
  min-height: 360px;
  overflow: auto;
  padding: 0 8px 4px;
  overscroll-behavior: contain;
}

.notice-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 28px 4px;
  color: #64748b;
  font-size: 0.82rem;
}

.notice-pager .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.notice-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #eef2f7;
  border-radius: 12px;
  margin-bottom: 8px;
  background: #fff;
  text-align: left;
  min-height: 62px;
}

.notice-item .meta {
  font-size: 0.74rem;
  color: #64748b;
  margin-top: 3px;
  line-height: 1.4;
}

.notice-item .title {
  font-size: 0.86rem;
  color: #0f172a;
  font-weight: 700;
}

.notice-item .actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.notice-item.status-unread { border-color: #fecaca; background: #fff7f7; }
.notice-item.status-restocked { border-color: #bbf7d0; background: #f0fdf4; }
.notice-item.status-muted { border-color: #bfdbfe; background: #f8fbff; }
.notice-item.status-done { border-color: #fde68a; background: #fffbeb; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  transition: 0.15s ease;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn-sm { padding: 4px 7px; font-size: 0.7rem; }
.btn-block { width: 100%; }
.btn-primary {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
}
.btn-ghost {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #2563eb;
}
.btn-danger {
  background: #fee2e2;
  color: var(--danger);
  border: 1px solid #fecaca;
}
.btn-note {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}
.btn-note.filled {
  background: #dcfce7;
  color: #047857;
  border: 1px solid #86efac;
}

.orders-section {
  padding: 0;
  overflow: hidden;
  width: 100%;
  border-radius: var(--radius);
  margin-bottom: 10px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: rgba(255, 255, 255, 0.94);
}

.orders-scroll {
  width: 100%;
  /* 表头 1 行 + 内容固定 10 行的可视高度 */
  height: calc(var(--row-h) * 11);
  max-height: calc(var(--row-h) * 11);
  overflow: auto;
  scrollbar-gutter: stable;
}

.orders-list {
  width: 100%;
  min-height: calc(var(--row-h) * 10);
}

.orders-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.96);
}

.orders-pager .pager-left,
.orders-pager .pager-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.orders-pager .pager-text {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1;
}

.orders-pager .pager-text strong {
  color: var(--text);
  font-weight: 700;
}

.pager-size {
  width: 72px;
  min-width: 72px;
  height: 32px;
  padding: 0 8px;
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  box-sizing: border-box;
}

.pager-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 32px;
  padding: 0 10px;
  font-size: 0.84rem;
  font-weight: 700;
  color: #334155;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  line-height: 1;
}

.btn-pager {
  height: 32px;
  min-height: 32px;
  padding: 0 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-pager:hover:not(:disabled) {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #2563eb;
}

.btn-pager:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #f8fafc;
}

.orders-header,
.order-row,
.order-placeholder {
  display: grid;
  width: 100%;
  box-sizing: border-box;
  /* 联系/售价/数量固定；只让链接吃剩余宽度 */
  grid-template-columns:
    40px
    118px
    minmax(120px, 1fr)
    90px
    90px
    48px
    150px
    102px
    236px;
  gap: 6px;
  align-items: center;
  justify-items: stretch;
  text-align: center;
  padding: 0 10px;
  min-height: var(--row-h);
  height: var(--row-h);
}

.orders-header {
  position: sticky;
  top: 0;
  z-index: 3;
  background: rgba(248, 250, 252, 0.96);
  border-bottom: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.btn-restock {
  background: #ef4444;
  color: #fff;
  border: 1px solid #ef4444;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-restock:hover { filter: brightness(0.96); }

.restock-detail {
  text-align: left;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.restock-pick {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  padding-right: 108px;
  cursor: pointer;
  color: #334155;
  position: relative;
}

.restock-pick::after {
  content: '点击修改提醒 ›';
  position: absolute;
  right: 12px;
  top: 10px;
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 600;
}

.restock-pick strong {
  font-size: 0.9rem;
  color: #0f172a;
}

.restock-pick span {
  font-size: 0.8rem;
  color: #64748b;
}

.restock-pick em {
  font-style: normal;
  font-size: 0.78rem;
  color: #94a3b8;
}

.restock-pick.active {
  border-color: #ef4444;
  background: #fff5f5;
  color: #ef4444;
}

.restock-pick.active::after {
  color: #ef4444;
}

.restock-pick.active strong,
.restock-pick.active span { color: #ef4444; }

.restock-remain {
  margin: 2px 0 0;
  font-size: 0.84rem;
  color: #475569;
}

.order-row {
  border-bottom: 1px solid rgba(226, 232, 240, 0.75);
  background: rgba(255, 255, 255, 0.35);
}

.order-row:hover { background: rgba(255, 255, 255, 0.58); }
.order-row.highlight { background: rgba(219, 234, 254, 0.75); }
.order-row.refund-row { background: rgba(254, 226, 226, 0.35); }

.order-placeholder {
  color: transparent;
  border-bottom: 1px dashed rgba(226, 232, 240, 0.55);
  pointer-events: none;
  background: transparent;
}

.order-no {
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
  white-space: nowrap;
  text-align: center;
  justify-self: center;
}

.row-actions {
  display: grid !important;
  grid-template-columns: 46px 42px 54px 42px 32px;
  gap: 4px;
  align-items: center;
  justify-content: center;
  justify-self: center;
  width: max-content;
  max-width: 100%;
}

.row-actions .btn {
  width: 100%;
  min-width: 0 !important;
  height: 28px;
  min-height: 28px;
  padding: 0 2px !important;
  margin: 0;
  font-size: 0.68rem !important;
  font-weight: 600;
  border-radius: 999px !important;
  border: 1px solid transparent !important;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-sizing: border-box;
  transform: none !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

.row-actions .btn:hover {
  transform: none !important;
}

/* 操作列统一：浅底 + 可见描边（有边框就全部有） */
.row-actions .btn-restock {
  background: #fff5f5 !important;
  color: #ef4444 !important;
  border-color: #ef4444 !important;
  text-align: center;
  justify-content: center;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.row-actions .btn-warn {
  background: #fff7ed !important;
  color: #ea580c !important;
  border-color: #f97316 !important;
}

.row-actions .btn-soft {
  background: #eff6ff !important;
  color: #2563eb !important;
  border-color: #3b82f6 !important;
}

.row-actions .btn-note {
  background: #f0f9ff !important;
  color: #0284c7 !important;
  border-color: #0ea5e9 !important;
}

.row-actions .btn-note.filled {
  background: #f0fdf4 !important;
  color: #059669 !important;
  border-color: #10b981 !important;
}

.row-actions .btn-danger {
  background: #fef2f2 !important;
  color: #dc2626 !important;
  border-color: #ef4444 !important;
}

.row-actions .btn-ghost {
  background: #f8fafc !important;
  color: #64748b !important;
  border-color: #94a3b8 !important;
}

.order-row .field-target,
.order-row .field-done {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 4px 6px;
  width: 100%;
  box-sizing: border-box;
  /* 去掉数字框上下增减箭头 */
  -moz-appearance: textfield;
  appearance: textfield;
}

.order-row .field-target::-webkit-outer-spin-button,
.order-row .field-target::-webkit-inner-spin-button,
.order-row .field-done::-webkit-outer-spin-button,
.order-row .field-done::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.progress-cell {
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
  text-align: center;
  justify-self: center;
}

.progress-cell.ok { color: var(--success); }
.progress-cell.bad { color: var(--danger); }

.money-info {
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--muted);
  white-space: normal;
  overflow: hidden;
  max-width: 100%;
  text-align: center;
}

.money-info.two-line {
  display: flex;
  flex-direction: column;
  gap: 1px;
  align-items: center;
  justify-content: center;
}

.money-info.refund-only {
  color: var(--danger);
  font-weight: 700;
  line-height: 1.2;
}

.money-info .profit { font-weight: 700; }
.money-info .profit.profit-pos,
.stat-value.profit-pos,
.stat-value.success { color: var(--success) !important; }
.money-info .profit.profit-neg,
.stat-value.profit-neg,
.stat-value.danger { color: var(--danger) !important; }
.money-info .profit.profit-zero,
.stat-value.profit-zero { color: var(--muted) !important; }
.money-info .refund { color: var(--danger); font-weight: 700; }

.price-empty {
  width: 100%;
  box-sizing: border-box;
  border: 1px dashed #93c5fd;
  background: #eff6ff;
  color: var(--primary);
  border-radius: 8px;
  padding: 5px 4px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.cleanup-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 8px 0 14px;
  padding: 0 12px;
}

.cleanup-chip {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.cleanup-chip:hover {
  border-color: #93c5fd;
  color: #2563eb;
  background: #eff6ff;
}

.cleanup-chip.active {
  border-color: #2563eb;
  background: #2563eb;
  color: #fff;
}

.cleanup-chip.danger {
  border-color: #fecaca;
  color: #dc2626;
  background: #fff5f5;
}

.cleanup-chip.danger.active {
  border-color: #dc2626;
  background: #dc2626;
  color: #fff;
}

.cleanup-date-wrap {
  margin: 0 28px 12px;
  text-align: left;
}

.cleanup-preview {
  margin: 0 20px 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 0.84rem;
  font-weight: 600;
}

.price-filled {
  cursor: pointer;
  border-radius: 8px;
  padding: 2px 4px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: center;
}

.price-filled:hover { background: rgba(255, 255, 255, 0.7); }

.order-row input,
.order-row select {
  height: 32px;
  padding: 3px 6px;
  font-size: 0.8rem;
  min-width: 0;
  width: 100%;
  text-align: center;
}

.order-row .field-link,
.order-row .field-business {
  text-align: left;
}

.order-row .field-contact {
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-row .field-link {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-row.collapsed,
.order-row.fold-summary {
  height: 34px;
  min-height: 34px;
  cursor: pointer;
  overflow: hidden;
  background: linear-gradient(90deg, rgba(219, 234, 254, 0.55), rgba(239, 246, 255, 0.35));
}

.order-row.collapsed * { pointer-events: none; }
.order-row.collapsed .fold-hint,
.order-row.fold-summary .fold-hint { pointer-events: auto; }

.fold-hint {
  grid-column: 1 / -1;
  font-size: 0.8rem;
  color: #1d4ed8;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-badge {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.66rem;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  cursor: pointer;
  border: none;
}


.modal {
  border: none;
  border-radius: 24px;
  padding: 0;
  width: calc(100% - 32px);
  max-width: 480px;
  max-height: min(90vh, 860px);
  overflow: auto;
  overscroll-behavior: contain;
  position: fixed;
  inset: 0;
  margin: auto;
  transform: none;
  height: fit-content;
  text-align: center;
}

dialog.modal[open] {
  position: fixed;
}

dialog.modal:not([open]) {
  display: none !important;
}

.modal-wide { max-width: 760px; }

.modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

dialog.modal[open] { display: block; }

.modal-close-x {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: #f1f5f9;
  color: #64748b;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.modal-close-x:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.modal form,
.modal > h3,
.modal > p,
.modal > div {
  padding-left: 28px;
  padding-right: 28px;
}

.modal h3 {
  padding-top: 28px;
  padding-left: 48px;
  padding-right: 48px;
  font-size: 1.12rem;
  text-align: center;
  color: #0f172a;
}

.modal h3.restock-title {
  padding-left: 48px;
  padding-right: 48px;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

.modal .hint {
  margin: 8px 0 14px;
  text-align: center;
  line-height: 1.55;
}

.modal label { text-align: left; }

.modal input,
.modal select,
.modal textarea {
  border: 1px solid #dbe3ef;
  background: #f8fafc;
}

.modal input:focus,
.modal select:focus,
.modal textarea:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  background: #fff;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  text-align: left;
}

.check-line {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  justify-content: center;
}

.modal-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 14px 24px 20px;
  flex-wrap: wrap;
}

.modal-actions .btn,
.restock-notify-actions .btn,
.reminder-footer .btn {
  min-width: 100px;
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  border: 1px solid transparent;
  box-shadow: none;
  transform: none;
}

.modal-actions .btn:hover,
.restock-notify-actions .btn:hover,
.reminder-footer .btn:hover {
  transform: none;
  filter: brightness(0.97);
}

.modal-actions .btn-primary,
.modal-actions .btn-confirm,
.btn-pill-primary {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

.modal-actions .btn-ghost,
.modal-actions .btn-cancel,
.modal-actions .btn-soft,
.btn-pill-soft {
  background: #eef2ff;
  color: #2563eb;
  border-color: #c7d2fe;
}

.modal-actions .btn-danger {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fecaca;
}

.btn-pill {
  border-radius: 999px !important;
  min-width: 0;
  min-height: 38px;
  padding: 9px 12px !important;
  font-size: 0.82rem !important;
  font-weight: 700;
  border: 1px solid transparent;
}

.btn-pill-mute {
  background: #f8fafc;
  color: #64748b;
  border-color: #e2e8f0;
}

.btn-pill-mute:hover { background: #f1f5f9; }

.btn-pill-red {
  background: #ef4444 !important;
  color: #fff !important;
  border-color: #ef4444 !important;
}

.btn-pill-yellow {
  background: #facc15 !important;
  color: #713f12 !important;
  border-color: #eab308 !important;
}

.btn-pill-blue {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #2563eb !important;
}

.btn-pill-green {
  background: #16a34a !important;
  color: #fff !important;
  border-color: #16a34a !important;
}

.restock-actions,
.restock-notify-actions.three {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  width: 100%;
  max-width: none;
  margin: 0;
  padding-left: 20px;
  padding-right: 20px;
  justify-content: center;
}

.restock-actions.four {
  flex-wrap: nowrap;
  gap: 6px;
  padding-left: 12px;
  padding-right: 12px;
}

.restock-actions.four .btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 9px 6px !important;
  font-size: 0.76rem !important;
}

.restock-actions .btn,
.restock-notify-actions.three .btn {
  width: auto;
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
}

.inline-form {
  margin-bottom: 12px;
  justify-content: center;
}

.inline-form input { flex: 1; min-width: 120px; }

.list-box {
  max-height: 280px;
  overflow: auto;
  padding-bottom: 8px;
  text-align: left;
}

.user-item, .type-item {
  display: grid;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.user-item { grid-template-columns: 1fr 80px 70px; }
.type-list-head,
.type-item,
.type-inline-add {
  grid-template-columns: minmax(120px, 1.4fr) 96px 96px 128px;
}
.type-inline-add {
  display: grid;
  gap: 8px;
  align-items: center;
  margin: 0 0 10px;
  padding: 10px;
  border: 1px dashed #93c5fd;
  border-radius: 10px;
  background: #f8fbff;
}
.type-inline-add input {
  margin: 0;
  height: 34px;
  box-sizing: border-box;
}
.type-inline-add .btn {
  width: 100%;
  height: 34px;
  min-height: 34px;
}
.type-list-head {
  display: grid;
  gap: 8px;
  align-items: center;
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}
.type-list-head span:first-child { text-align: left; }
.type-item .type-name { text-align: left; }
.type-item .type-cost,
.type-item .type-price { text-align: center; }
.type-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}
.type-actions .btn {
  min-width: 52px;
  padding: 5px 8px;
}
.reminder-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 0 0 auto;
}

.role-tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #1d4ed8;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.84rem;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
}
.toast.show { opacity: 1; }

.toast.toast-in-modal {
  position: absolute;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
}

.modal-schedule {
  max-width: 500px;
  width: calc(100% - 32px);
  height: auto;
  max-height: min(620px, 90vh);
  text-align: left;
  overflow: hidden;
  border-radius: 24px;
}

dialog.modal.modal-schedule[open] {
  display: flex !important;
  flex-direction: column;
  position: fixed;
}

.modal-schedule > h3,
.modal-schedule > .hint {
  text-align: center;
  flex: 0 0 auto;
}

.modal-schedule > .hint {
  margin: 4px 0 10px;
}

.reminder-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-bottom: 4px;
}

.reminder-form {
  display: block;
  overflow: visible;
  padding-bottom: 0;
}

.schedule-stage {
  height: 236px;
  min-height: 236px;
  max-height: 236px;
  margin: 0 0 8px;
  position: relative;
}

.full-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  text-align: left;
}

.full-label input,
.full-label textarea {
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  padding: 10px 12px;
}

.full-label textarea {
  resize: none;
  min-height: 56px;
}

.schedule-block {
  margin: 2px 0 12px;
}

.schedule-label {
  font-size: 0.84rem;
  color: #64748b;
  margin-bottom: 8px;
  text-align: left;
}

.mode-seg,
.date-seg {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-btn,
.date-btn,
.time-slot {
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #334155;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.86rem;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.mode-btn {
  flex: 1 1 calc(50% - 8px);
  min-width: 0;
  text-align: center;
  padding: 10px 6px;
}

.date-seg {
  margin-bottom: 10px;
}

.date-btn {
  flex: 1;
  text-align: center;
  padding: 12px 10px;
  font-size: 0.9rem;
}

.mode-btn.active,
.date-btn.active,
.time-slot.active {
  border-color: #ef4444;
  color: #ef4444;
  background: #fff5f5;
  font-weight: 600;
}

.mode-btn:hover,
.date-btn:hover,
.time-slot:hover:not(.disabled) {
  border-color: #fca5a5;
}

.schedule-panel {
  height: 100%;
  margin-bottom: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.time-grid,
.minute-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px;
  scrollbar-width: thin;
}

.time-slot {
  padding: 11px 4px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.time-slot.disabled {
  opacity: 0.32;
  cursor: not-allowed;
  background: #f8fafc;
  pointer-events: none;
}

.daily-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.92rem;
  color: #334155;
  background: #fff;
  border: 1px solid #eef2f7;
  border-radius: 12px;
  padding: 14px 12px;
  margin-top: 4px;
}

.time-picker {
  position: relative;
}

.time-picker-display {
  min-width: 96px;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 8px;
  padding: 8px 34px 8px 12px;
  cursor: pointer;
  font-size: 0.95rem;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  position: relative;
}

.time-picker-display::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  border: 1.5px solid #94a3b8;
  border-radius: 50%;
  box-sizing: border-box;
  background:
    linear-gradient(#94a3b8, #94a3b8) 50% 28% / 1.5px 4px no-repeat,
    linear-gradient(#94a3b8, #94a3b8) 58% 50% / 3.5px 1.5px no-repeat;
}

.time-picker-display:hover {
  border-color: #fca5a5;
}

.time-picker-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  display: flex;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.time-col {
  width: 64px;
  max-height: 196px;
  overflow-y: auto;
  border-right: 1px solid #f1f5f9;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}

.time-col:last-child { border-right: none; }

.time-item {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  padding: 9px 0;
  cursor: pointer;
  color: #475569;
  font-variant-numeric: tabular-nums;
}

.time-item:hover { background: #f8fafc; }
.time-item.active {
  background: #f1f5f9;
  color: #0f172a;
  font-weight: 700;
  box-shadow: inset 0 0 0 1.5px #111827;
}

.day-select {
  width: 64px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fff;
}

.reminder-footer.schedule-actions.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex: 0 0 auto;
  margin: 0;
  padding: 14px 28px 22px;
  border-top: 1px solid #eef2f7;
  background: #fff;
}

.reminder-footer .btn-cancel,
.reminder-footer .btn-confirm {
  flex: 1;
  max-width: 180px;
}

.btn-cancel {
  background: #eef2ff;
  color: #2563eb;
  border: 1.5px solid #c7d2fe;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}

.btn-confirm {
  background: #ef4444;
  color: #fff;
  border: 1.5px solid #ef4444;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}

.btn-confirm:hover { filter: brightness(0.96); }
.btn-cancel:hover { background: #e0e7ff; }

.restock-notify {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
}

.restock-notify.hidden {
  display: none !important;
}

.restock-notify-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  padding: 24px 22px 22px;
  text-align: center;
}

.restock-notify-card h3 {
  font-size: 1.15rem;
  margin-bottom: 10px;
  color: #0f172a;
}

.restock-notify-card p {
  color: #475569;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-line;
  margin-bottom: 18px;
  text-align: left;
}

.restock-notify-actions {
  display: flex;
  gap: 10px;
}

.restock-notify-actions.three {
  padding-left: 0;
  padding-right: 0;
}

.order-row.highlight {
  outline: 2px solid #ef4444;
  outline-offset: -2px;
  background: #fff5f5;
}

@media (max-width: 520px) {
  .mode-btn { flex: 1 1 100%; }
  .time-grid,
  .minute-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .modal-schedule {
    max-height: min(92vh, 640px);
  }
}


@media (max-width: 1100px) {
  .stats-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .orders-header { display: none; }
  .orders-scroll {
    height: auto;
    max-height: none;
    overflow: visible;
  }
  .orders-list {
    height: auto;
    min-height: 0;
  }
  .order-row {
    grid-template-columns: 1fr 1fr;
    height: auto;
    min-height: var(--row-h);
    padding: 10px 12px;
  }
}

@media (max-width: 640px) {
  .stats-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-row { grid-template-columns: 1fr; }
  .filter-bar { gap: 6px; }
}
