/* ============================================================
 * 收粮管理系统 - 共享样式
 * ============================================================ */
:root {
  --primary: #2e7d32;
  --primary-dark: #1b5e20;
  --primary-light: #e8f5e9;
  --accent: #f9a825;
  --danger: #c62828;
  --bg: #f4f6f4;
  --card: #ffffff;
  --text: #263238;
  --muted: #78909c;
  --border: #e0e6e3;
  --shadow: 0 2px 12px rgba(46, 125, 50, .08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  background: #fff;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c8d6cd; border-radius: 4px; }

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 16px; border: none; border-radius: 6px;
  font-size: 14px; background: var(--primary); color: #fff;
  transition: opacity .15s;
}
.btn:hover { opacity: .88; }
.btn-accent { background: var(--accent); color: #4e342e; }
.btn-danger { background: var(--danger); }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 4px; }
.btn-block { width: 100%; }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 12px; line-height: 1.7; white-space: nowrap;
}
.tag-green { background: var(--primary-light); color: var(--primary-dark); }
.tag-orange { background: #fff8e1; color: #f57f17; }
.tag-red { background: #ffebee; color: var(--danger); }
.tag-blue { background: #e3f2fd; color: #1565c0; }
.tag-gray { background: #eceff1; color: #607d8b; }

.card {
  background: var(--card); border-radius: 10px; box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card-title {
  font-size: 16px; font-weight: 600; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.card-title::before {
  content: ""; display: inline-block; width: 4px; height: 16px;
  background: var(--primary); border-radius: 2px; margin-right: 8px;
  vertical-align: -2px;
}
.card-title { justify-content: flex-start; }
.card-title .spacer { flex: 1; }
.card-title > span:first-child { display: inline-flex; align-items: center; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td {
  padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.tbl th {
  background: #f7faf8; color: #546e7a; font-weight: 600; position: sticky; top: 0;
}
table.tbl tbody tr:hover { background: #f4faf5; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow: auto; max-height: calc(100vh - 260px); border: 1px solid var(--border); border-radius: 8px; }

/* ---------- 门户首页 ---------- */
.portal {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 40px 20px;
  background: linear-gradient(160deg, #1b5e20 0%, #2e7d32 45%, #66bb6a 100%);
}
.portal-logo {
  text-align: center; color: #fff; margin-bottom: 42px;
}
.portal-logo .icon {
  width: 84px; height: 84px; margin: 0 auto 16px; border-radius: 22px;
  background: rgba(255, 255, 255, .16); display: flex; align-items: center; justify-content: center;
}
.portal-logo .icon svg { width: 48px; height: 48px; }
.portal-logo h1 { font-size: 32px; letter-spacing: 6px; font-weight: 700; }
.portal-logo p { opacity: .8; margin-top: 6px; letter-spacing: 2px; }
.version-cards { display: flex; gap: 28px; flex-wrap: wrap; justify-content: center; }
.version-card {
  width: 300px; background: rgba(255, 255, 255, .97); border-radius: 16px;
  padding: 34px 28px; text-align: center; cursor: pointer;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .22);
  transition: transform .2s, box-shadow .2s;
}
.version-card:hover { transform: translateY(-6px); box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.version-card svg { width: 72px; height: 72px; margin-bottom: 14px; }
.version-card h2 { font-size: 22px; color: var(--primary-dark); margin-bottom: 8px; }
.version-card p { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.version-card .go {
  display: inline-block; padding: 9px 34px; border-radius: 22px;
  background: var(--primary); color: #fff; font-size: 15px;
}
.version-card.mobile .go { background: var(--accent); color: #4e342e; }
.portal-foot { color: rgba(255, 255, 255, .65); margin-top: 42px; font-size: 13px; letter-spacing: 1px; }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #1b5e20, #43a047); padding: 20px;
}
.login-box {
  width: 380px; max-width: 100%; background: #fff; border-radius: 14px;
  padding: 36px 34px; box-shadow: 0 16px 50px rgba(0, 0, 0, .28);
}
.login-box .l-icon { text-align: center; margin-bottom: 8px; }
.login-box .l-icon svg { width: 56px; height: 56px; }
.login-box h2 { text-align: center; color: var(--primary-dark); margin-bottom: 4px; }
.login-box .l-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-box .field { margin-bottom: 16px; }
.login-box .field label { display: block; margin-bottom: 6px; color: #546e7a; font-size: 13px; }
.login-err { color: var(--danger); font-size: 13px; min-height: 20px; text-align: center; margin-bottom: 8px; }
.login-tip { margin-top: 16px; text-align: center; color: var(--muted); font-size: 12px; }
.login-back { display: block; text-align: center; margin-top: 12px; color: var(--primary); font-size: 13px; }

/* ---------- 电脑版框架 ---------- */
.ds-shell { display: flex; min-height: 100vh; }
.ds-side {
  width: 216px; background: linear-gradient(180deg, #1b5e20, #2e7d32);
  color: #fff; display: flex; flex-direction: column; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
}
.ds-brand {
  display: flex; align-items: center; gap: 10px; padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .15);
}
.ds-brand svg { width: 34px; height: 34px; }
.ds-brand b { font-size: 17px; letter-spacing: 1px; }
.ds-brand small { display: block; font-size: 11px; opacity: .7; font-weight: 400; }
.ds-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.ds-nav a {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  border-radius: 8px; color: rgba(255, 255, 255, .82); margin-bottom: 4px;
  font-size: 14px; transition: background .15s;
}
.ds-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.ds-nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.ds-nav a.active { background: rgba(255, 255, 255, .92); color: var(--primary-dark); font-weight: 600; }
.ds-side .side-foot { padding: 14px 18px; border-top: 1px solid rgba(255, 255, 255, .15); font-size: 12px; opacity: .75; }

.ds-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ds-topbar {
  height: 60px; background: #fff; box-shadow: var(--shadow);
  display: flex; align-items: center; padding: 0 22px; gap: 14px;
  position: sticky; top: 0; z-index: 20;
}
.ds-topbar h3 { font-size: 17px; color: var(--primary-dark); }
.ds-topbar .spacer { flex: 1; }
.ds-topbar .t-date { color: var(--muted); font-size: 13px; }
.ds-user {
  display: flex; align-items: center; gap: 8px; color: var(--text);
  background: var(--primary-light); padding: 5px 14px 5px 6px; border-radius: 20px; font-size: 13px;
}
.ds-user .avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.ds-content { padding: 20px 22px; flex: 1; }
.ds-page { display: none; }
.ds-page.active { display: block; animation: fadeIn .25s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; }
.toolbar .spacer { flex: 1; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat-card {
  background: #fff; border-radius: 10px; padding: 18px 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px; position: relative; overflow: hidden;
}
.stat-card .s-icon {
  width: 52px; height: 52px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.stat-card .s-icon svg { width: 26px; height: 26px; }
.stat-card .s-label { color: var(--muted); font-size: 13px; }
.stat-card .s-value { font-size: 24px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-card .s-sub { font-size: 12px; color: var(--muted); }
.bg-green { background: var(--primary-light); }
.bg-amber { background: #fff8e1; }
.bg-blue { background: #e3f2fd; }
.bg-red { background: #ffebee; }

.grid-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.chart-bars { display: flex; align-items: flex-end; gap: 14px; height: 190px; padding: 12px 6px 0; }
.chart-item { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.chart-item .bar {
  width: 70%; max-width: 46px; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, #66bb6a, #2e7d32);
  min-height: 4px; position: relative; transition: height .4s;
}
.chart-item .bar span {
  position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: var(--muted); white-space: nowrap;
}
.chart-item .lbl { font-size: 12px; color: var(--muted); margin-top: 6px; }

.mini-list { font-size: 13px; }
.mini-list .row {
  display: flex; justify-content: space-between; padding: 9px 2px;
  border-bottom: 1px dashed var(--border); gap: 10px;
}
.mini-list .row:last-child { border-bottom: none; }
.mini-list .m { color: var(--muted); font-size: 12px; }

/* ---------- 表单弹窗 ---------- */
.modal-mask {
  display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .45);
  z-index: 100; align-items: center; justify-content: center; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: 720px; max-width: 100%;
  max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3); animation: fadeIn .2s;
}
.modal.modal-sm { width: 460px; }
.modal-head {
  padding: 16px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head b { font-size: 16px; color: var(--primary-dark); }
.modal-close { background: none; border: none; font-size: 20px; color: var(--muted); line-height: 1; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.f-item label { display: block; font-size: 13px; color: #546e7a; margin-bottom: 5px; }
.f-item label i { color: var(--danger); font-style: normal; }

.calc-panel {
  grid-column: 1 / -1; background: var(--primary-light); border: 1px dashed #81c784;
  border-radius: 8px; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 8px 26px;
}
.calc-panel .c-item { font-size: 13px; color: #33691e; }
.calc-panel .c-item b { font-size: 18px; color: var(--primary-dark); margin-left: 4px; font-variant-numeric: tabular-nums; }
.calc-panel .c-item.amount b { color: #e65100; font-size: 22px; }

/* ---------- 打印小票 ---------- */
.receipt {
  width: 320px; background: #fff; color: #000; font-size: 12px;
  padding: 14px 16px; display: none; line-height: 1.5;
}
.receipt.show { display: block; }
.receipt h4 { text-align: center; font-size: 16px; margin-bottom: 2px; letter-spacing: 2px; }
.receipt .r-sub { text-align: center; font-size: 11px; margin-bottom: 8px; }
.receipt .r-sep { border-top: 1px dashed #000; margin: 6px 0; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt td { padding: 2px 0; font-size: 12px; }
.receipt td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.receipt .r-total td { font-weight: bold; font-size: 14px; }
.receipt .r-upper { font-size: 11px; }
.receipt .r-foot { text-align: center; margin-top: 10px; font-size: 11px; }
@media print {
  body * { visibility: hidden !important; }
  #receipt-print, #receipt-print * { visibility: visible !important; }
  #receipt-print { display: block !important; position: absolute; left: 0; top: 0; width: 76mm; }
}

/* ---------- 手机版框架 ---------- */
.mb-shell { max-width: 560px; margin: 0 auto; min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; }
.mb-header {
  background: linear-gradient(135deg, #1b5e20, #43a047); color: #fff;
  padding: 14px 16px; position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}
.mb-header .h-icon svg { width: 30px; height: 30px; }
.mb-header b { font-size: 17px; letter-spacing: 1px; }
.mb-header small { display: block; font-size: 11px; opacity: .75; font-weight: 400; }
.mb-header .spacer { flex: 1; }
.mb-header .h-btn {
  background: rgba(255, 255, 255, .18); border: none; color: #fff;
  border-radius: 16px; padding: 5px 12px; font-size: 12px;
}
.mb-content { flex: 1; padding: 12px 12px 78px; }
.mb-page { display: none; }
.mb-page.active { display: block; animation: fadeIn .25s; }

.mb-tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; background: #fff; display: flex;
  border-top: 1px solid var(--border); z-index: 40; box-shadow: 0 -2px 12px rgba(0, 0, 0, .06);
}
.mb-tabbar a {
  flex: 1; text-align: center; padding: 7px 0 5px; color: var(--muted); font-size: 11px;
}
.mb-tabbar a svg { width: 22px; height: 22px; display: block; margin: 0 auto 2px; }
.mb-tabbar a.active { color: var(--primary); font-weight: 600; }

.mb-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.mb-stat { background: #fff; border-radius: 10px; padding: 13px 14px; box-shadow: var(--shadow); }
.mb-stat .l { font-size: 12px; color: var(--muted); }
.mb-stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mb-stat .s { font-size: 11px; color: var(--muted); }

.mb-card { background: #fff; border-radius: 10px; padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.mb-card .ct { font-size: 15px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.mb-list-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 2px;
  border-bottom: 1px dashed var(--border); font-size: 13px;
}
.mb-list-item:last-child { border-bottom: none; }
.mb-list-item .li-main { flex: 1; min-width: 0; }
.mb-list-item .li-main .t1 { font-weight: 600; }
.mb-list-item .li-main .t2 { font-size: 12px; color: var(--muted); }
.mb-list-item .li-side { text-align: right; font-variant-numeric: tabular-nums; }
.mb-list-item .li-side .v { font-weight: 700; font-size: 15px; }
.mb-list-item .li-side .s { font-size: 11px; color: var(--muted); }

.mb-form .f-item { margin-bottom: 12px; }
.mb-form .f-item label { display: block; font-size: 13px; color: #546e7a; margin-bottom: 5px; }
.mb-calc {
  background: var(--primary-light); border: 1px dashed #81c784; border-radius: 8px;
  padding: 10px 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-bottom: 12px;
}
.mb-calc .c-item { font-size: 12px; color: #33691e; }
.mb-calc .c-item b { font-size: 16px; color: var(--primary-dark); margin-left: 3px; }
.mb-calc .c-item.amount { grid-column: 1 / -1; }
.mb-calc .c-item.amount b { color: #e65100; font-size: 22px; }
.mb-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.mb-quick .q {
  background: #fff; border-radius: 10px; padding: 12px 4px; text-align: center;
  box-shadow: var(--shadow); font-size: 12px; color: var(--text);
}
.mb-quick .q svg { width: 26px; height: 26px; display: block; margin: 0 auto 5px; }

.mb-sheet-mask {
  display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 100;
}
.mb-sheet-mask.show { display: block; }
.mb-sheet {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: 560px; background: #fff; border-radius: 14px 14px 0 0;
  z-index: 101; max-height: 86vh; display: none; flex-direction: column;
}
.mb-sheet.show { display: flex; animation: slideUp .22s; }
@keyframes slideUp { from { transform: translate(-50%, 40px); opacity: .5; } to { transform: translate(-50%, 0); opacity: 1; } }
.mb-sheet .sh-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.mb-sheet .sh-head b { font-size: 16px; color: var(--primary-dark); }
.mb-sheet .sh-body { padding: 14px 16px; overflow-y: auto; }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .version-cards { gap: 18px; }
  .version-card { width: 100%; max-width: 340px; padding: 26px 22px; }
  .portal-logo h1 { font-size: 26px; }
}

.empty-tip { text-align: center; color: var(--muted); padding: 30px 0; font-size: 13px; }
.text-red { color: var(--danger); }
.text-green { color: var(--primary); }
.text-orange { color: #ef6c00; }
