:root {
    color-scheme: light;
    --primary: #176b52;
    --primary-dark: #10513e;
    --primary-soft: #e8f4ef;
    --accent: #e9a23b;
    --ink: #1e2c27;
    --muted: #6d7c76;
    --line: #dce5e1;
    --surface: #ffffff;
    --background: #f3f6f4;
    --danger: #b83a3a;
    --shadow: 0 10px 35px rgba(25, 58, 46, 0.07);
    font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--background); line-height: 1.55; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.58; }

.app-header {
    color: white;
    background: linear-gradient(125deg, #10513e, #1d795d);
    padding: calc(22px + env(safe-area-inset-top)) 18px 26px;
}
.header-inner { max-width: 820px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
h1 { margin: 2px 0 0; font-size: clamp(21px, 5vw, 29px); letter-spacing: 0.04em; }
.eyebrow, .section-kicker { margin: 0; font-size: 11px; letter-spacing: 0.18em; opacity: 0.72; }
.page-shell { width: min(820px, calc(100% - 28px)); margin: -10px auto calc(36px + env(safe-area-inset-bottom)); position: relative; }
.panel { background: var(--surface); border: 1px solid rgba(220, 229, 225, 0.85); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.login-panel { max-width: 460px; margin: 38px auto; padding: 32px; text-align: center; }
.login-panel form { text-align: left; margin-top: 24px; }
.login-mark { width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); font-size: 30px; font-weight: 800; }
h2, h3, p { margin-top: 0; }
h2 { margin-bottom: 0; font-size: 22px; }
h3 { margin-bottom: 3px; font-size: 17px; }
.muted { color: var(--muted); font-size: 13px; margin-bottom: 0; }
.section-heading, .lines-heading, .line-heading, .total-bar, .line-total { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.section-heading { margin-bottom: 22px; }
.section-kicker { color: var(--primary); opacity: 1; font-weight: 700; }
.section-badge { color: var(--primary); background: var(--primary-soft); border-radius: 999px; padding: 5px 11px; font-size: 12px; white-space: nowrap; }
.lines-heading { margin: 26px 0 14px; align-items: flex-end; }
b { color: var(--danger); font-weight: 400; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: #415049; font-size: 13px; }
.field-wide { grid-column: 1 / -1; }
input, select, textarea {
    width: 100%;
    min-height: 45px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--ink);
    background: #fbfcfb;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
textarea { resize: vertical; min-height: 76px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 3px rgba(23, 107, 82, 0.1); }
.button { min-height: 42px; border-radius: 10px; border: 1px solid transparent; padding: 9px 16px; font-weight: 650; transition: background 0.15s, transform 0.1s; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button-primary { color: white; background: var(--primary); }
.button-primary:hover:not(:disabled) { background: var(--primary-dark); }
.button-secondary { color: var(--primary); background: var(--primary-soft); border-color: #d4e9df; }
.button-ghost { color: white; background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.35); }
.button-block { width: 100%; min-height: 48px; margin-top: 14px; }
.submit-button { font-size: 17px; margin-top: 16px; }
.text-button { border: 0; background: transparent; color: var(--danger); padding: 5px; }

.order-lines { display: grid; gap: 13px; }
.line-card { padding: 15px; border: 1px solid var(--line); background: #fbfdfc; border-radius: 13px; }
.line-heading { margin-bottom: 12px; }
.line-heading strong { color: var(--primary); }
.line-grid { gap: 12px; }
.line-total { justify-content: flex-end; margin-top: 12px; color: var(--muted); font-size: 13px; }
.line-total strong { color: var(--ink); margin-left: 8px; }
.total-bar { margin-top: 18px; padding: 16px 18px; border-radius: 12px; color: var(--primary-dark); background: var(--primary-soft); }
.total-bar strong { font-size: 24px; }
.message { min-height: 0; margin: 12px 0 0; font-size: 14px; white-space: pre-wrap; }
.message:empty { display: none; }
.message.error { color: var(--danger); }
.message.success { color: var(--primary); background: var(--primary-soft); border-radius: 10px; padding: 12px; }

.recent-panel { margin-bottom: 0; }
.recent-orders { display: grid; gap: 12px; }
.recent-card { border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.recent-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; background: #f7faf8; }
.recent-head strong { font-size: 15px; }
.sync-badge { border-radius: 999px; padding: 3px 9px; font-size: 12px; white-space: nowrap; color: #8b5b13; background: #fff2d9; }
.sync-badge.synced { color: var(--primary); background: var(--primary-soft); }
.recent-body { padding: 13px 14px; }
.recent-meta { margin: 0 0 5px; color: #43534c; font-size: 14px; overflow-wrap: anywhere; }
.recent-lines { margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--line); }
.recent-line { margin: 3px 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.recent-total { margin: 10px 0 0; text-align: right; font-weight: 700; color: var(--primary-dark); }
.empty-state { color: var(--muted); text-align: center; padding: 24px 8px; margin: 0; }

@media (max-width: 560px) {
    .app-header { padding-left: 15px; padding-right: 15px; }
    .page-shell { width: min(100% - 20px, 820px); }
    .panel { padding: 17px; border-radius: 15px; }
    .login-panel { padding: 25px 20px; margin-top: 24px; }
    .form-grid { grid-template-columns: 1fr; gap: 12px; }
    .field-wide { grid-column: auto; }
    .line-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .line-grid .field-wide { grid-column: 1 / -1; }
    .lines-heading { align-items: center; }
    .lines-heading .muted { max-width: 180px; }
    .section-heading { margin-bottom: 18px; }
}

@media (max-width: 350px) {
    .line-grid { grid-template-columns: 1fr; }
    .line-grid .field-wide { grid-column: auto; }
    .lines-heading { align-items: flex-start; flex-direction: column; }
}
