:root {
    --bg: #f5f7fb;
    --bg-soft: #eef2f8;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --line: #e3e9f1;
    --line-strong: #cbd5e1;
    --text: #0f172a;
    --muted: #5b6b82;
    --dim: #8a99ad;
    --green: #0b8f63;
    --amber: #a16207;
    --red: #c24141;
    --blue: #2563eb;
    --blue-soft: rgba(37, 99, 235, .09);
    --blue-line: rgba(37, 99, 235, .22);
    --green-soft: rgba(11, 143, 99, .09);
    --green-line: rgba(11, 143, 99, .22);
    --amber-soft: rgba(161, 98, 7, .08);
    --amber-line: rgba(161, 98, 7, .25);
    --red-soft: rgba(194, 65, 65, .08);
    --red-line: rgba(194, 65, 65, .28);
    --ok-text: #076b4b;
    --err-text: #a12626;
    --info-text: #1e4ed8;
    --warn-text: #92400e;
    --input-bg: #ffffff;
    --btn-bg: #ffffff;
    --hover: rgba(15, 23, 42, .045);
    --avatar-bg: #e8edf5;
    --preview-bg: #f8fafc;
    --sidebar-bg: rgba(255, 255, 255, .78);
    --body-glow: #e4ecfb;
    --login-brand-bg: #f2f6fd;
    --grid-line: rgba(15, 23, 42, .04);
    --table-line: rgba(15, 23, 42, .075);
    --mono-bg: #f1f5f9;
    --shadow: 0 12px 34px rgba(15, 23, 42, .06);
    --shadow-strong: 0 18px 46px rgba(15, 23, 42, .10);
    --radius: 14px;
}

html[data-theme="dark"] {
    --bg: #0f1115;
    --bg-soft: #13161c;
    --panel: #171a21;
    --panel-2: #1c2029;
    --line: #272c37;
    --line-strong: #3a4252;
    --text: #e8ecf3;
    --muted: #8b93a3;
    --dim: #646d7c;
    --green: #35c98b;
    --amber: #f0b45a;
    --red: #ef6b6b;
    --blue: #5b9dff;
    --blue-soft: rgba(91, 157, 255, .10);
    --blue-line: rgba(91, 157, 255, .20);
    --green-soft: rgba(53, 201, 139, .08);
    --green-line: rgba(53, 201, 139, .26);
    --amber-soft: rgba(240, 180, 90, .08);
    --amber-line: rgba(240, 180, 90, .26);
    --red-soft: rgba(239, 107, 107, .08);
    --red-line: rgba(239, 107, 107, .30);
    --ok-text: #b6f0d5;
    --err-text: #ffc0c0;
    --info-text: #cfe0ff;
    --warn-text: #ffe0a8;
    --input-bg: #11141a;
    --btn-bg: #1a1e26;
    --hover: rgba(255, 255, 255, .04);
    --avatar-bg: #252b36;
    --preview-bg: #0d1017;
    --sidebar-bg: rgba(15, 17, 21, .72);
    --body-glow: #1a2536;
    --login-brand-bg: #0c0f14;
    --grid-line: rgba(255, 255, 255, .025);
    --table-line: rgba(255, 255, 255, .055);
    --mono-bg: #0d1017;
    --shadow: 0 12px 34px rgba(0, 0, 0, .25);
    --shadow-strong: 0 18px 46px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

html { background: var(--bg); }

body {
    background:
        radial-gradient(1100px 560px at 10% -10%, var(--body-glow) 0%, transparent 60%),
        var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
::selection { background: var(--blue-soft); color: var(--text); }

.layout {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    border-right: 1px solid var(--line);
    background: var(--sidebar-bg);
    backdrop-filter: blur(14px);
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center;
    background: linear-gradient(145deg, #2b6cff, #1a3d9e);
    color: #fff;
    font-weight: 800; letter-spacing: -.04em;
    box-shadow: 0 8px 22px rgba(43, 108, 255, .25);
}
.brand-name { font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.brand-sub { color: var(--muted); font-size: 11px; margin-top: 2px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label { color: var(--dim); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; padding: 0 10px; margin-bottom: 4px; }
.nav a, .nav .nav-item {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 9px 10px; border-radius: 9px;
    color: var(--muted); font-size: 13px;
    transition: background .15s ease, color .15s ease;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a.active { background: var(--blue-soft); color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue-line); }
.nav .disabled { opacity: .45; cursor: default; }
.nav .tag { font-size: 9px; color: var(--dim); border: 1px solid var(--line); border-radius: 999px; padding: 1px 6px; }

.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.user-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 6px 10px; }
.user-name { font-size: 12px; font-weight: 600; }
.user-role { color: var(--muted); font-size: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--avatar-bg); color: var(--muted); font-size: 11px; flex: 0 0 auto; }
.logout { width: 100%; border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 8px; padding: 8px 10px; font-size: 12px; transition: .15s ease; }
.logout:hover { color: var(--text); border-color: var(--line-strong); background: var(--hover); }
.sidebar-theme { margin-top: 9px; display: flex; justify-content: flex-end; }

.theme-toggle {
    display: inline-flex; align-items: center; gap: 7px;
    border: 1px solid var(--line); background: var(--panel); color: var(--muted);
    border-radius: 999px; padding: 6px 10px; font-size: 11px; line-height: 1;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--line-strong); background: var(--hover); }
.theme-toggle svg { width: 14px; height: 14px; flex: 0 0 auto; }
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: inline-block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.main { padding: 32px 40px 56px; max-width: 1280px; width: 100%; margin-inline: auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 0 0 auto; }
.eyebrow { color: var(--green); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
h1 { margin: 0; font-size: 28px; line-height: 1.2; letter-spacing: -.03em; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 7px; max-width: 720px; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.card {
    display: block;
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--line); border-radius: var(--radius); padding: 17px;
    box-shadow: var(--shadow);
    transition: transform .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.card-label { color: var(--muted); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
.card-value { font-size: 26px; font-weight: 700; letter-spacing: -.03em; margin-top: 8px; }
.card-note { color: var(--dim); font-size: 11px; margin-top: 3px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel h2 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.panel-hint { color: var(--muted); font-size: 12px; }
.panel-divider { border-top: 1px solid var(--line); margin: 16px 0; }

.document-launcher { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.document-launcher-fields {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(120px, .7fr) auto auto auto;
    gap: 8px;
    align-items: end;
    flex: 0 1 680px;
}
.document-launcher-fields .field label { font-size: 11px; }
.document-launcher-fields .btn { white-space: nowrap; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-3 .span-2 { grid-column: span 2; }
.form-grid-3 .span-3 { grid-column: span 3; }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid-4 .span-4 { grid-column: span 4; }
.form-section { padding-bottom: 22px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.form-section:last-of-type { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }
.form-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 13px; }
.form-section-head h2 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { color: var(--muted); font-size: 12px; }
.field input, .field select, .field textarea {
    width: 100%; border: 1px solid var(--line); background: var(--input-bg); color: var(--text);
    border-radius: 9px; padding: 9px 11px; outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.field input::placeholder, .field textarea::placeholder { color: var(--dim); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue-line); box-shadow: 0 0 0 3px var(--blue-soft); }
.field textarea { min-height: 78px; resize: vertical; }
.field .hint { color: var(--dim); font-size: 11px; }
.field .error { color: var(--red); font-size: 11px; }
.field input[type="checkbox"] { width: auto; accent-color: var(--blue); }
.field input[type="file"] { padding: 7px; background: var(--panel-2); }

.actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--btn-bg); color: var(--text); border-radius: 9px; padding: 9px 14px; font-size: 12px; font-weight: 600; transition: .15s ease; }
.btn:hover { border-color: var(--line-strong); background: var(--hover); }
.btn-primary { background: linear-gradient(180deg, #3c7cff, #2b5fd9); border-color: #3c7cff; color: #fff; box-shadow: 0 8px 20px rgba(43, 95, 217, .25); }
.btn-primary:hover { border-color: #5b9dff; background: linear-gradient(180deg, #4b87ff, #2b5fd9); }
.btn-danger { color: var(--err-text); border-color: var(--red-line); background: var(--red-soft); }
.btn-danger:hover { border-color: var(--red); background: var(--red-soft); }
.btn-sm { padding: 6px 10px; font-size: 11px; border-radius: 7px; }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar input, .toolbar select { border: 1px solid var(--line); background: var(--input-bg); color: var(--text); border-radius: 9px; padding: 8px 10px; font-size: 12px; outline: none; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--blue-line); box-shadow: 0 0 0 3px var(--blue-soft); }
.toolbar .search { min-width: 240px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--table-line); font-size: 12px; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 11px; letter-spacing: .03em; text-transform: uppercase; }
td { color: var(--text); }
th.num, td.num { text-align: right; white-space: nowrap; }
th.actions-col, td.actions-col { text-align: right; white-space: nowrap; }
td.actions-col .btn + .btn { margin-left: 5px; }
.cell-sub { color: var(--muted); font-size: 10px; margin-top: 2px; }
.table-link { color: var(--blue); font-weight: 600; }
.table-link:hover { text-decoration: underline; }
.muted { color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table-actions form { display: inline; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.thumb { width: 42px; height: 42px; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; background: var(--preview-bg); }
.thumb-empty { width: 42px; height: 42px; display: grid; place-items: center; border: 1px dashed var(--line-strong); border-radius: 8px; color: var(--dim); font-size: 10px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; font-size: 10px; border: 1px solid var(--line); color: var(--muted); }
.badge-active { color: var(--green); border-color: var(--green-line); background: var(--green-soft); }
.badge-suspended { color: var(--amber); border-color: var(--amber-line); background: var(--amber-soft); }
.badge-blue { color: var(--blue); border-color: var(--blue-line); background: var(--blue-soft); }
.badge-muted { color: var(--muted); background: var(--panel-2); }

.alert { border-radius: 10px; padding: 12px 14px; font-size: 12px; margin-bottom: 16px; line-height: 1.7; }
.alert-error { border: 1px solid var(--red-line); background: var(--red-soft); color: var(--err-text); }
.alert-ok { border: 1px solid var(--green-line); background: var(--green-soft); color: var(--ok-text); }
.alert-info { border: 1px solid var(--blue-line); background: var(--blue-soft); color: var(--info-text); }
.alert-warn { border: 1px solid var(--amber-line); background: var(--amber-soft); color: var(--warn-text); }
.credentials { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--mono-bg); border: 1px dashed var(--amber-line); border-radius: 9px; padding: 10px 12px; margin-top: 8px; color: var(--warn-text); }

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid var(--table-line); font-size: 12px; }
.kv:first-child { border-top: 0; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { text-align: right; color: var(--text); }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.list-main { min-width: 0; }
.list-title { font-size: 12px; font-weight: 600; }
.list-sub { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.logo-preview { width: 160px; max-width: 100%; height: auto; max-height: 70px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: var(--preview-bg); padding: 4px; }
.stamp-preview { width: 52px; height: 52px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: var(--preview-bg); padding: 4px; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; border-top: 1px solid var(--table-line); margin-top: 12px; font-size: 11px; color: var(--muted); }
.pagination .pages { display: flex; gap: 8px; }
.pagination a, .pagination span { padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; }
.pagination a:hover { background: var(--hover); color: var(--text); }

/* 订单编辑器 */
.order-lines { display: flex; flex-direction: column; gap: 10px; }
.order-line {
    display: block;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel-2);
}
.order-line-main {
    display: grid;
    grid-template-columns: minmax(160px, 1.4fr) minmax(150px, 1.5fr) 82px 108px 112px 32px;
    gap: 8px;
    align-items: end;
}
.order-line-extra {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    align-items: end;
    margin-top: 9px;
    padding-top: 9px;
    border-top: 1px dashed var(--line);
}
.order-line .field { gap: 4px; }
.order-line .field label { font-size: 10px; color: var(--dim); }
.order-line .field input, .order-line .field select { padding: 7px 9px; font-size: 12px; }
.order-line .amount { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; background: var(--mono-bg); }
.order-line .remove-line {
    width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 7px;
    background: transparent; color: var(--muted); align-self: end;
}
.order-line .remove-line:hover { color: var(--red); border-color: var(--red-line); background: var(--red-soft); }
.order-summary {
    display: flex; justify-content: flex-end; gap: 28px; align-items: flex-start;
    margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line);
}
.order-summary .sum-label { color: var(--muted); font-size: 11px; text-align: right; }
.order-summary .sum-value { font-size: 20px; font-weight: 700; letter-spacing: -.02em; text-align: right; }
.order-summary .base { color: var(--dim); font-size: 11px; text-align: right; margin-top: 2px; }
.order-tabs {
    display: flex; align-items: center; gap: 4px; padding: 4px;
    margin: 0 0 18px; border: 1px solid var(--line); border-radius: 11px;
    background: var(--panel-2); overflow-x: auto;
}
.order-tab {
    flex: none; height: 34px; padding: 0 16px; border: 0; border-radius: 8px;
    background: transparent; color: var(--muted); font-size: 12px; cursor: pointer;
    white-space: nowrap; transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}
.order-tab:hover { color: var(--text); }
.order-tab.active {
    background: var(--panel); color: var(--text); font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.order-panel[hidden] { display: none; }
.customer-panel[hidden] { display: none; }
.order-alerts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.order-alerts .badge { padding: 5px 9px; }

@media (max-width: 900px) {
    .order-line-main { grid-template-columns: 1fr 1fr; }
    .order-line-extra { grid-template-columns: 1fr 1fr; }
    .order-line .remove-line { width: 100%; }
}

/* 登录页 */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
    position: relative;
}
.login-theme { position: absolute; top: 22px; right: 24px; z-index: 5; }
.login-brand {
    position: relative;
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-right: 1px solid var(--line);
    background:
        radial-gradient(700px 420px at 20% 10%, rgba(43, 108, 255, .22), transparent 65%),
        radial-gradient(500px 400px at 90% 90%, rgba(53, 201, 139, .10), transparent 70%),
        var(--login-brand-bg);
    overflow: hidden;
}
.login-brand::after {
    content: "";
    position: absolute; inset: 0;
    background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .7), transparent 80%);
    pointer-events: none;
}
.login-brand-content { position: relative; z-index: 1; max-width: 480px; }
.login-brand h1 { font-size: 44px; line-height: 1.1; margin: 18px 0 14px; }
.login-brand p { color: var(--muted); font-size: 14px; line-height: 1.8; }
.login-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 26px; }
.login-badge { border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; color: var(--muted); font-size: 11px; background: var(--panel); }
.login-foot { position: relative; z-index: 1; color: var(--dim); font-size: 11px; }
.login-form-wrap { display: grid; place-items: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 390px; }
.login-card h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.03em; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card .field { margin-bottom: 13px; }
.login-card .btn-primary { width: 100%; padding: 11px 14px; margin-top: 4px; }
.login-note { margin-top: 18px; color: var(--dim); font-size: 11px; line-height: 1.7; border-top: 1px solid var(--line); padding-top: 14px; }
.login-note code { background: var(--mono-bg); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; }

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-footer { margin-top: 0; }
    .main { padding: 24px 18px 48px; }
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2, .grid-3, .form-grid, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
    .form-grid .span-2, .form-grid-3 .span-2, .form-grid-3 .span-3 { grid-column: span 1; }
    .document-launcher { align-items: flex-start; flex-direction: column; }
    .document-launcher-fields { width: 100%; flex-basis: auto; grid-template-columns: 1fr 1fr; }
    .login-page { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .login-form-wrap { min-height: 100vh; }
    .login-theme { top: 16px; right: 16px; }
    h1 { font-size: 24px; }
    .order-summary { justify-content: flex-start; }
}

/* 模板中心 */
.template-import-row {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}
.template-import-row .field { flex: 1 1 420px; }
.tpl-edit-table input,
.tpl-edit-table select {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    background: var(--input-bg);
    color: var(--text);
    border-radius: 7px;
    padding: 7px 8px;
    font-size: 12px;
    outline: none;
}
.tpl-edit-table input:focus,
.tpl-edit-table select:focus {
    border-color: var(--blue-line);
    box-shadow: 0 0 0 3px var(--blue-soft);
}
.tpl-cell-input { max-width: 120px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.tpl-sample { color: var(--muted); font-size: 11px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-check { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--muted); font-size: 11px; }
.tpl-check input { width: auto; accent-color: var(--blue); }

/* 法律页面 */
.legal-body { min-height: 100vh; }
.legal-shell { width: min(1160px, calc(100% - 48px)); margin: 0 auto; padding: 26px 0 40px; }
.legal-header {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    padding: 14px 18px; border: 1px solid var(--line); border-radius: 14px;
    background: var(--panel); box-shadow: var(--shadow);
}
.legal-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.legal-nav a {
    padding: 7px 11px; border-radius: 8px; color: var(--muted); font-size: 12px;
    border: 1px solid transparent;
}
.legal-nav a:hover { color: var(--text); background: var(--hover); }
.legal-nav a.active { color: var(--blue); border-color: var(--blue-line); background: var(--blue-soft); }
.legal-theme { flex: none; }
.legal-main {
    margin-top: 18px; padding: 48px 56px 42px; border: 1px solid var(--line);
    border-radius: 18px; background: var(--panel); box-shadow: var(--shadow);
}
.legal-kicker { color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.legal-main h1 { margin: 12px 0 12px; font-size: 38px; letter-spacing: -.04em; }
.legal-lead { max-width: 760px; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.9; }
.legal-meta {
    margin-top: 20px; padding: 10px 0 20px; border-bottom: 1px solid var(--line);
    color: var(--dim); font-size: 12px;
}
.legal-content { max-width: 820px; margin-top: 26px; }
.legal-content h2 {
    margin: 30px 0 10px; font-size: 17px; letter-spacing: -.01em;
}
.legal-content p { margin: 0 0 12px; color: var(--text); line-height: 1.95; }
.legal-content ul { margin: 6px 0 14px; padding-left: 20px; }
.legal-content li { margin: 5px 0; line-height: 1.9; }
.legal-content strong { font-weight: 600; }
.legal-footer {
    margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--line);
    color: var(--muted); font-size: 12px; line-height: 1.9;
}
.legal-bottom {
    display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding: 16px 2px 0; color: var(--dim); font-size: 11px;
}
.legal-bottom a { margin-left: 12px; color: var(--muted); }
.login-legal { margin-top: 16px; color: var(--dim); font-size: 11px; line-height: 1.8; }
.login-legal a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.login-sponsor { margin-top: 10px; color: var(--dim); font-size: 11px; }
.login-sponsor a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.sidebar-legal { display: flex; gap: 10px; margin-top: 10px; font-size: 10px; color: var(--dim); }
.sidebar-legal a:hover { color: var(--text); }
.sidebar-sponsor { margin-top: 6px; font-size: 10px; color: var(--dim); }
.sidebar-sponsor a { color: var(--muted); }
.sidebar-sponsor a:hover { color: var(--text); }
@media (max-width: 760px) {
    .legal-shell { width: calc(100% - 24px); padding-top: 12px; }
    .legal-header { align-items: flex-start; flex-wrap: wrap; }
    .legal-main { padding: 30px 22px; }
    .legal-main h1 { font-size: 28px; }
}

/* 公告 */
.announcement-strip {
    display: flex; align-items: center; gap: 10px;
    margin: -2px 0 16px; padding: 8px 12px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--panel-2); color: var(--muted); font-size: 12px;
}
.announcement-strip-label {
    flex: none; color: var(--blue); font-size: 10px; letter-spacing: .12em;
}
.announcement-strip-title {
    min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--text); font-weight: 500;
}
.announcement-strip-title:hover { color: var(--blue); }
.announcement-strip-count { flex: none; color: var(--dim); font-size: 11px; }
.announcement-strip-link { flex: none; color: var(--muted); font-size: 11px; }
.announcement-strip-link:hover { color: var(--text); }

.announcement-list { display: grid; gap: 12px; max-width: 900px; }
.announcement-item {
    padding: 22px 24px; border: 1px solid var(--line); border-radius: 12px;
    background: var(--panel);
}
.announcement-item.is-unread { border-color: var(--blue-line); }
.announcement-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.announcement-meta { color: var(--dim); font-size: 11px; }
.announcement-item h2 { margin: 4px 0 12px; font-size: 19px; letter-spacing: -.02em; }
.announcement-body { color: var(--text); font-size: 13px; line-height: 1.9; word-break: break-word; }

.announcement-admin-list { display: grid; gap: 0; }
.announcement-admin-item {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px 0; border-bottom: 1px solid var(--line);
}
.announcement-admin-item:last-child { border-bottom: 0; }
.announcement-admin-main { min-width: 0; }
.announcement-admin-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.announcement-admin-meta { margin-top: 3px; color: var(--dim); font-size: 11px; }

.announcement-pop {
    position: fixed; right: 24px; bottom: 24px; z-index: 80;
    width: min(370px, calc(100vw - 32px));
    padding: 18px 20px 16px; border: 1px solid var(--line); border-radius: 14px;
    background: var(--panel); box-shadow: var(--shadow-strong);
    opacity: 0; transform: translateY(18px) scale(.98); pointer-events: none;
    transition: opacity .3s ease, transform .3s cubic-bezier(.2, .8, .2, 1);
}
.announcement-pop.is-visible { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.announcement-pop-close {
    position: absolute; top: 7px; right: 9px; width: 26px; height: 26px;
    border: 0; border-radius: 50%; background: transparent; color: var(--dim);
    font-size: 20px; line-height: 1; display: grid; place-items: center;
}
.announcement-pop-close:hover { color: var(--text); background: var(--hover); }
.announcement-pop-eyebrow { color: var(--blue); font-size: 10px; letter-spacing: .12em; }
.announcement-pop h3 { margin: 6px 28px 7px 0; font-size: 16px; line-height: 1.45; letter-spacing: -.01em; }
.announcement-pop p {
    margin: 0; color: var(--muted); font-size: 12px; line-height: 1.75;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.announcement-pop-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.announcement-pop-extra { display: block; margin-bottom: 9px; color: var(--dim); font-size: 10px; }
.announcement-pop-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.announcement-pop-actions form { margin: 0; }

@media (max-width: 760px) {
    .announcement-strip { flex-wrap: wrap; }
    .announcement-strip-title { flex-basis: calc(100% - 44px); }
    .announcement-pop { right: 16px; bottom: 16px; }
}

/* 客户详情：五类单证实時预览 */
.doc-preview-panel { padding-bottom: 18px; }
.doc-preview-head { align-items: flex-start; margin-bottom: 14px; }
.doc-preview-head .panel-hint { margin-top: 4px; line-height: 1.55; }
.doc-preview-orders { display: flex; align-items: center; gap: 8px; flex: none; }
.doc-preview-orders label { color: var(--muted); font-size: 11px; }
.doc-preview-orders select {
    height: 32px; min-width: 190px; padding: 0 28px 0 10px;
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--panel-2); color: var(--text); font-size: 12px;
}
.doc-preview-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-bottom: 12px;
}
.doc-preview-tabs {
    display: flex; align-items: center; gap: 3px; padding: 3px;
    border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2);
    overflow-x: auto;
}
.doc-preview-tab {
    flex: none; height: 28px; padding: 0 12px; border: 0; border-radius: 7px;
    background: transparent; color: var(--muted); font-size: 12px; cursor: pointer;
    transition: background .16s ease, color .16s ease, box-shadow .16s ease;
    white-space: nowrap;
}
.doc-preview-tab:hover { color: var(--text); }
.doc-preview-tab.active {
    background: var(--panel); color: var(--text); font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.doc-preview-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.doc-preview-stage {
    height: 878px; padding: 14px; overflow: auto;
    border: 1px solid var(--line); border-radius: 12px;
    background: #e8ecef;
}
.doc-preview-stage iframe {
    display: block; width: 100%; height: 850px;
    border: 0; background: #fff;
}
@media (max-width: 980px) {
    .doc-preview-head { flex-direction: column; }
    .doc-preview-orders { width: 100%; }
    .doc-preview-orders select { flex: 1; }
    .doc-preview-bar { align-items: flex-start; flex-direction: column; }
    .doc-preview-actions { width: 100%; justify-content: flex-end; }
    .doc-preview-stage { height: 720px; }
    .doc-preview-stage iframe { height: 692px; }
}

/* 工作台：汇率换算 */
.fx-panel {
    padding: 20px 22px;
    background:
        radial-gradient(340px 190px at 102% -12%, var(--blue-soft), transparent 72%),
        var(--panel);
}
.fx-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 17px;
}
.fx-heading { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.fx-mark {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border: 1px solid var(--blue-line);
    border-radius: 11px;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 19px;
    font-weight: 700;
    line-height: 1;
}
.fx-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fx-title-row h2 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.fx-tag {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 7px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel-2);
    color: var(--dim);
    font-size: 10px;
    letter-spacing: .02em;
}
.fx-desc { color: var(--muted); font-size: 11px; line-height: 1.65; margin-top: 3px; }
.fx-desc a { color: var(--blue); }
.fx-desc a:hover { text-decoration: underline; }
.fx-meta {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--dim);
    font-size: 11px;
    white-space: nowrap;
    padding-top: 4px;
}
.fx-meta::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px var(--green-soft);
}
#fx-converter[data-state="loading"] .fx-meta::before { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); animation: fx-pulse 1.4s ease-in-out infinite; }
#fx-converter[data-state="error"] .fx-meta { color: var(--red); }
#fx-converter[data-state="error"] .fx-meta::before { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
@keyframes fx-pulse {
    0%, 100% { opacity: .35; }
    50% { opacity: 1; }
}
.fx-body {
    display: grid;
    grid-template-columns: minmax(0, 1.38fr) minmax(275px, .62fr);
    gap: 14px;
    align-items: stretch;
}
.fx-form {
    display: grid;
    grid-template-columns: minmax(125px, .78fr) minmax(145px, 1fr) 42px minmax(145px, 1fr);
    gap: 10px;
    align-items: end;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-2);
}
.fx-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fx-field label { color: var(--muted); font-size: 11px; }
.fx-amount-shell {
    display: flex;
    align-items: center;
    height: 44px;
    padding: 0 11px 0 0;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--input-bg);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.fx-amount-shell:focus-within { border-color: var(--blue-line); box-shadow: 0 0 0 3px var(--blue-soft); }
.fx-amount-shell input {
    width: 100%;
    min-width: 0;
    height: 100%;
    border: 0;
    padding: 0 9px 0 11px;
    background: transparent;
    color: var(--text);
    font-size: 16px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    outline: none;
}
.fx-amount-shell input::-webkit-inner-spin-button,
.fx-amount-shell input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.fx-amount-shell input[type="number"] { -moz-appearance: textfield; }
.fx-code { flex: 0 0 auto; color: var(--dim); font-size: 10px; letter-spacing: .04em; }
.fx-select {
    width: 100%;
    height: 44px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--input-bg);
    color: var(--text);
    font-size: 12px;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.fx-select:focus { border-color: var(--blue-line); box-shadow: 0 0 0 3px var(--blue-soft); }
.fx-swap {
    width: 42px;
    height: 42px;
    align-self: end;
    margin-bottom: 1px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--panel);
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    display: grid;
    place-items: center;
    transition: color .15s ease, border-color .15s ease, background .15s ease, transform .15s ease;
}
.fx-swap:hover { color: var(--blue); border-color: var(--blue-line); background: var(--blue-soft); transform: rotate(180deg); }
.fx-output {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 104px;
    padding: 14px 16px;
    border: 1px solid var(--blue-line);
    border-radius: 12px;
    background:
        linear-gradient(160deg, var(--blue-soft), transparent 72%),
        var(--panel);
}
.fx-output-label { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.fx-output-main {
    display: flex;
    align-items: baseline;
    gap: 7px;
    margin-top: 4px;
    min-width: 0;
}
.fx-output-main #fx-result {
    font-size: 28px;
    font-weight: 750;
    line-height: 1.15;
    letter-spacing: -.035em;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.fx-output-code { color: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.fx-output-rate { color: var(--muted); font-size: 10.5px; line-height: 1.55; margin-top: 5px; font-variant-numeric: tabular-nums; }
#fx-converter[data-state="error"] .fx-output { border-color: var(--red-line); background: var(--red-soft); }
#fx-converter[data-state="error"] .fx-output-rate { color: var(--red); }
#fx-converter[data-state="loading"] .fx-output-main #fx-result,
#fx-converter[data-state="loading"] .fx-output-rate { opacity: .45; }

@media (max-width: 980px) {
    .fx-body { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
    .fx-head { flex-direction: column; gap: 7px; }
    .fx-meta { padding-top: 0; }
    .fx-form {
        grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr);
        padding: 11px;
    }
    .fx-amount { grid-column: 1 / -1; }
    .fx-output-main #fx-result { font-size: 24px; }
}

/* 模板中心：分类、卡片、缩略图预览 */
.tpl-category-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
}
.tpl-category-nav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    transition: .15s ease;
}
.tpl-category-nav a:hover { border-color: var(--blue-line); color: var(--blue); background: var(--blue-soft); }
.tpl-category-nav a small {
    min-width: 18px;
    padding: 1px 5px;
    border-radius: 999px;
    background: var(--panel-2);
    color: var(--dim);
    text-align: center;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}
.tpl-type-block { scroll-margin-top: 18px; margin-bottom: 26px; }
.tpl-type-block + .tpl-type-block { padding-top: 22px; border-top: 1px solid var(--line); }
.tpl-type-block:last-child { margin-bottom: 0; }
.tpl-type-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.tpl-type-head h3 { margin: 0 0 1px; font-size: 16px; letter-spacing: -.015em; }
.tpl-type-head .mono { color: var(--dim); font-size: 10px; letter-spacing: .06em; }
.tpl-type-count { color: var(--muted); font-size: 11px; }
.tpl-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}
.tpl-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--panel);
    box-shadow: 0 8px 22px rgba(15, 23, 42, .045);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.tpl-card:hover {
    transform: translateY(-2px);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-strong);
}
.tpl-card-cover {
    display: grid;
    place-items: center;
    color: inherit;
    text-decoration: none;
    width: 100%;
    aspect-ratio: 210 / 297;
    padding: 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: var(--preview-bg);
    overflow: hidden;
    cursor: zoom-in;
}
.tpl-card-cover img {
    grid-area: 1 / 1;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}
.tpl-source-badge,
.tpl-zoom-badge {
    grid-area: 1 / 1;
    position: relative;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    padding: 3px 7px;
    border: 1px solid rgba(255, 255, 255, .32);
    border-radius: 999px;
    background: rgba(11, 30, 24, .72);
    color: #fff;
    font-size: 10px;
    line-height: 1.3;
    backdrop-filter: blur(4px);
}
.tpl-source-badge { align-self: start; justify-self: start; margin: 8px; }
.tpl-source-excel { background: rgba(32, 78, 160, .82); }
.tpl-zoom-badge {
    align-self: end;
    justify-self: end;
    margin: 8px;
    opacity: 0;
    transform: translateY(3px);
    transition: .15s ease;
}
.tpl-card-cover:hover .tpl-zoom-badge { opacity: 1; transform: translateY(0); }
.tpl-no-image {
    display: grid;
    place-items: center;
    cursor: pointer;
    background:
        linear-gradient(145deg, var(--blue-soft), transparent 60%),
        var(--preview-bg);
}
.tpl-placeholder-icon {
    grid-area: 1 / 1;
    display: grid;
    place-items: center;
    width: 74px;
    height: 92px;
    border: 1px solid var(--blue-line);
    border-radius: 9px;
    background: var(--panel);
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    box-shadow: 0 8px 18px rgba(37, 99, 235, .10);
}
.tpl-card-body { display: flex; flex: 1; flex-direction: column; gap: 7px; padding: 12px 13px 10px; }
.tpl-card-title { font-size: 14px; font-weight: 700; line-height: 1.35; letter-spacing: -.012em; }
.tpl-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 10px; }
.tpl-card-meta .mono { font-size: 10px; }
.tpl-card-desc { color: var(--muted); font-size: 11.5px; line-height: 1.55; }
.tpl-card-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 0 13px 13px; }
.tpl-card-actions form { margin: 0; }
.tpl-preview-modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px; }
.tpl-preview-modal[hidden] { display: none; }
.tpl-preview-backdrop { position: absolute; inset: 0; background: rgba(7, 12, 20, .74); backdrop-filter: blur(4px); }
.tpl-preview-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(920px, 100%);
    max-height: 92vh;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel);
    box-shadow: 0 30px 90px rgba(0, 0, 0, .34);
}
.tpl-preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--line);
}
.tpl-preview-head h2 { margin: 0; font-size: 15px; }
.tpl-preview-close {
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--btn-bg);
    color: var(--muted);
    font-size: 21px;
    line-height: 1;
}
.tpl-preview-close:hover { color: var(--text); background: var(--hover); }
.tpl-preview-stage {
    display: flex;
    flex: 1;
    justify-content: center;
    min-height: 0;
    padding: 16px;
    overflow: auto;
    background: var(--preview-bg);
}
.tpl-preview-stage img {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 70vh;
    height: auto;
    object-fit: contain;
    background: #fff;
    box-shadow: 0 12px 34px rgba(0, 0, 0, .18);
}
.tpl-preview-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px 14px;
    border-top: 1px solid var(--line);
}
body.tpl-modal-open { overflow: hidden; }

/* 制单选择器在增加模板下拉后保持可读 */
.document-launcher { flex-wrap: wrap; gap: 10px; }
.document-launcher > .field { flex: 1 1 130px; min-width: 120px; }
.document-launcher-fields {
    flex: 1 1 100%;
    max-width: 100%;
    grid-template-columns: minmax(150px, 1.15fr) minmax(120px, .8fr) minmax(140px, .9fr) minmax(105px, .65fr) auto auto;
}

@media (max-width: 900px) {
    .tpl-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .document-launcher-fields { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
    .tpl-card-grid { grid-template-columns: 1fr; }
    .tpl-preview-modal { padding: 10px; }
    .tpl-preview-foot { align-items: flex-start; flex-direction: column; }
    .tpl-card-cover { aspect-ratio: 210 / 280; }
}

/* 系统更新页 */
.readonly-value {
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--muted);
    border-radius: 9px;
    padding: 9px 11px;
    font-size: 12px;
    min-height: 38px;
    display: flex;
    align-items: center;
}
.update-file-note { color: var(--dim); font-size: 11px; margin-top: 6px; }

/* WhatsApp workspace */
.page-sub { color: var(--muted); font-size: 12px; line-height: 1.7; margin-top: 7px; max-width: 680px; }
.wa-layout {
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    gap: 16px;
    align-items: stretch;
    /* Keep the workspace inside one viewport; side panels scroll internally. */
    height: calc(100vh - 176px);
    max-height: calc(100vh - 176px);
    overflow: hidden;
}
.wa-sidebar {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    max-height: 100%;
}
.wa-sidebar-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 18px 13px; }
.wa-sidebar-head h2, .wa-conversation-head h2 { margin: 0; font-size: 15px; }
.wa-account-list { padding: 0 10px 8px; display: flex; flex-direction: column; gap: 5px; }
.wa-account-card { display: flex; align-items: center; gap: 10px; padding: 9px 9px; border: 1px solid transparent; border-radius: 10px; color: var(--text); transition: .15s ease; }
.wa-account-card:hover { background: var(--hover); border-color: var(--line); }
.wa-account-card.is-active { background: var(--blue-soft); border-color: var(--blue-line); }
.wa-account-avatar, .wa-contact-avatar { flex: none; display: grid; place-items: center; width: 31px; height: 31px; border-radius: 9px; background: linear-gradient(135deg, #37c98f, #128c7e); color: #fff; font-size: 12px; font-weight: 700; }
.wa-contact-avatar { width: 37px; height: 37px; font-size: 13px; border-radius: 50%; background: linear-gradient(135deg, #5b8def, #3957c9); }
.wa-contact-avatar-lg { width: 42px; height: 42px; font-size: 15px; }
.wa-account-copy { min-width: 0; flex: 1; }
.wa-account-name { font-size: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-account-meta { font-size: 10px; color: var(--muted); margin-top: 2px; }
.wa-status-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--dim); }
.wa-status-ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.wa-status-warn { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.wa-status-danger { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.wa-status-muted { background: var(--dim); }
.wa-divider { border-top: 1px solid var(--line); margin: 6px 18px 0; }
.wa-conversation-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 16px 18px 10px; }
.wa-conversation-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding: 0 8px 8px;
}
.wa-conversation-item { display: flex; gap: 10px; padding: 10px 9px; border-radius: 10px; color: var(--text); border: 1px solid transparent; }
.wa-conversation-item:hover { background: var(--hover); }
.wa-conversation-item.is-active { background: var(--blue-soft); border-color: var(--blue-line); }
.wa-conversation-copy { min-width: 0; flex: 1; }
.wa-conversation-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.wa-conversation-top strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-conversation-top small { font-size: 10px; color: var(--muted); flex: none; }
.wa-conversation-preview { font-size: 11px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-unread { flex: none; align-self: center; min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; border-radius: 999px; background: var(--blue); color: #fff; font-size: 10px; font-weight: 700; }
.wa-sidebar-foot { margin-top: auto; padding: 13px 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; color: var(--dim); font-size: 10px; }
.wa-main {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    max-height: 100%;
}
.wa-thread-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.wa-thread-contact { display: flex; align-items: center; gap: 11px; min-width: 0; }
.wa-thread-contact h2 { margin: 0; font-size: 15px; }
.wa-thread-sub { color: var(--muted); font-size: 10px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-thread-actions { display: flex; align-items: center; gap: 9px; flex: none; }
.wa-last-seen { color: var(--muted); font-size: 10px; }
.wa-translation-bar {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--panel-2);
}
.wa-translation-bar-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.wa-translation-bar-label { color: var(--text); font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.wa-translation-bar-hint { color: var(--dim); font-size: 9px; white-space: nowrap; }
.wa-language-field { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.wa-language-select {
    border: 1px solid var(--line);
    background: var(--input-bg);
    color: var(--text);
    border-radius: 7px;
    padding: 4px 6px;
    font-size: 10px;
    outline: none;
    max-width: 150px;
}
.wa-language-select:focus { border-color: var(--blue-line); box-shadow: 0 0 0 3px var(--blue-soft); }
.wa-auto-translate.is-active { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue); }
.wa-auto-state { color: var(--dim); font-size: 9px; }
.wa-message-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 22px 20px;
    background: radial-gradient(circle at 20% 10%, var(--blue-soft), transparent 35%), var(--panel-2);
}
.wa-message { display: flex; margin-bottom: 12px; }
.wa-message-out { justify-content: flex-end; }
.wa-bubble { max-width: min(72%, 560px); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 7px; background: var(--panel); box-shadow: 0 4px 12px rgba(15,23,42,.04); }
.wa-message-out .wa-bubble { background: var(--blue-soft); border-color: var(--blue-line); }
.wa-message-body { font-size: 12px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.wa-translation { margin-top: 8px; padding-top: 7px; border-top: 1px dashed var(--line-strong); }
.wa-translation-label { color: var(--muted); font-size: 9px; margin-bottom: 3px; }
.wa-translation-text { color: var(--info-text); font-size: 12px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.wa-message-meta { display: flex; justify-content: flex-end; align-items: center; gap: 8px; color: var(--dim); font-size: 9px; margin-top: 5px; }
.wa-message-status { font-size: 9px; }
.wa-message-status-sent { color: var(--dim); }
.wa-message-status-delivered { color: var(--green); }
.wa-message-status-read { color: var(--blue); font-weight: 700; }
.wa-message-status-failed { color: var(--red); }
.wa-translate-btn { border: 0; background: transparent; color: var(--blue); font-size: 9px; cursor: pointer; padding: 0; }
.wa-translate-btn:hover { text-decoration: underline; }
.wa-translate-btn:disabled { color: var(--muted); cursor: wait; }
.wa-composer { display: flex; gap: 10px; padding: 13px 18px; border-top: 1px solid var(--line); background: var(--panel); align-items: flex-end; }
.wa-composer-input { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.wa-composer textarea { flex: none; width: 100%; min-height: 44px; max-height: 130px; resize: vertical; border: 1px solid var(--line); background: var(--input-bg); color: var(--text); border-radius: 10px; padding: 10px 12px; outline: none; font-size: 12px; line-height: 1.6; }
.wa-composer textarea:focus { border-color: var(--blue-line); box-shadow: 0 0 0 3px var(--blue-soft); }
.wa-composer-hint { color: var(--muted); font-size: 9px; line-height: 1.4; }
.wa-composer-hint.is-error { color: var(--red); }
.wa-translation-preview {
    border: 1px solid var(--blue-line);
    background: var(--blue-soft);
    border-radius: 9px;
    padding: 8px 10px;
    max-height: 110px;
    overflow-y: auto;
}
.wa-translation-preview[hidden] { display: none; }
.wa-translation-preview-label { color: var(--muted); font-size: 9px; margin-bottom: 3px; }
.wa-translation-preview-text { color: var(--info-text); font-size: 12px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.wa-translation-preview.is-error { border-color: var(--red-line, var(--line-strong)); background: var(--red-soft, var(--panel-2)); }
.wa-translation-preview.is-error .wa-translation-preview-text { color: var(--red); }
.wa-composer-side { display: flex; flex-direction: column; gap: 7px; align-items: flex-end; flex: none; }
.wa-translate-option { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.wa-translate-option input { width: auto; accent-color: var(--blue); }
.wa-composer-readonly { color: var(--muted); font-size: 12px; }
.wa-qr-view { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 36px 24px; background: radial-gradient(circle at 50% 0%, var(--green-soft), transparent 45%); }
.wa-qr-copy { max-width: 610px; text-align: center; }
.wa-qr-copy h2 { margin: 7px 0 8px; font-size: 22px; }
.wa-qr-copy p { color: var(--muted); font-size: 12px; line-height: 1.8; margin: 0 auto; max-width: 540px; }
.wa-qr-points { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.wa-qr-points span { color: var(--green); border: 1px solid var(--green-line); background: var(--green-soft); border-radius: 999px; padding: 4px 9px; font-size: 10px; }
.wa-qr-card { text-align: center; border: 1px solid var(--line-strong); border-radius: 16px; padding: 15px; background: var(--panel); box-shadow: var(--shadow); }
.wa-qr-card img { width: 224px; height: 224px; display: block; image-rendering: pixelated; border-radius: 8px; }
.wa-qr-placeholder { width: 224px; height: 224px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 11px; background: var(--panel-2); border-radius: 8px; }
.wa-qr-spinner { width: 24px; height: 24px; border: 2px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: wa-spin .8s linear infinite; }
@keyframes wa-spin { to { transform: rotate(360deg); } }
.wa-qr-meta { color: var(--dim); font-size: 10px; margin-top: 10px; }
.wa-qr-actions { display: flex; gap: 9px; align-items: center; }
.wa-qr-tip { color: var(--muted); font-size: 10px; text-align: center; max-width: 620px; line-height: 1.7; }
.wa-onboarding { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 30px; align-items: start; padding: 30px; }
.wa-onboarding-copy h2 { margin: 8px 0 10px; font-size: 21px; }
.wa-onboarding-copy p { color: var(--muted); font-size: 12px; line-height: 1.8; max-width: 620px; }
.wa-steps { display: flex; flex-direction: column; gap: 12px; margin: 22px 0 0; padding: 0; list-style: none; }
.wa-steps li { display: flex; gap: 11px; align-items: flex-start; }
.wa-steps li > span { flex: none; width: 26px; height: 26px; border: 1px solid var(--blue-line); background: var(--blue-soft); color: var(--blue); border-radius: 8px; display: grid; place-items: center; font-size: 10px; font-weight: 700; }
.wa-steps strong { display: block; font-size: 12px; margin-bottom: 2px; }
.wa-steps small { color: var(--muted); font-size: 11px; line-height: 1.6; }
.wa-create-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 13px; }
.wa-create-title { font-size: 14px; font-weight: 700; }
.wa-create-card .field label { font-size: 11px; }
.wa-create-hint { color: var(--dim); font-size: 10px; line-height: 1.6; }
.wa-create-readonly { color: var(--muted); font-size: 12px; line-height: 1.7; }
.wa-new-panel { margin-top: 16px; }
.wa-new-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.wa-alert-command { margin-top: 7px; display: inline-block; padding: 4px 8px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.wa-alert-detail { margin-top: 4px; color: var(--muted); font-size: 10px; }
.wa-empty-thread { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 24px; }
.wa-empty-icon { font-size: 34px; color: var(--blue); margin-bottom: 8px; }
.wa-empty-thread h2 { font-size: 20px; margin: 0 0 7px; }
.wa-empty-thread p { color: var(--muted); font-size: 12px; line-height: 1.8; max-width: 520px; }
.wa-empty-hint { color: var(--dim); font-size: 10px; margin-top: 13px; }
.wa-empty-actions { display: flex; gap: 8px; margin-top: 16px; }
.wa-empty-conversations { padding: 26px 16px; line-height: 1.8; }
@media (max-width: 1000px) {
    .wa-layout, .wa-onboarding { grid-template-columns: 1fr; }
    .wa-layout { height: auto; max-height: none; overflow: visible; }
    .wa-sidebar, .wa-main { height: auto; max-height: none; min-height: auto; }
    .wa-conversation-list { flex: none; min-height: 0; max-height: 250px; }
    .wa-new-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
    .wa-new-form { grid-template-columns: 1fr; }
    .wa-thread-head { align-items: flex-start; flex-direction: column; }
    .wa-translation-bar { align-items: flex-start; flex-direction: column; padding: 9px 14px; }
    .wa-translation-bar-hint { display: none; }
    .wa-composer { flex-direction: column; align-items: stretch; }
    .wa-composer-side { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
    .wa-bubble { max-width: 88%; }
}

.wa-dialog {
    width: min(430px, calc(100vw - 32px));
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0;
    color: var(--text);
    background: var(--panel);
    box-shadow: var(--shadow-strong);
}
.wa-dialog::backdrop { background: rgba(15, 23, 42, .45); }
.wa-dialog form { display: flex; flex-direction: column; gap: 13px; padding: 22px; }
.wa-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.wa-dialog-head h2 { margin: 4px 0 0; font-size: 19px; }
.wa-dialog-close {
    width: 28px;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.wa-dialog-close:hover { color: var(--text); background: var(--hover); }
.wa-dialog-sub { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.wa-dialog .field label { font-size: 11px; }
.wa-dialog-error { color: var(--red); font-size: 11px; line-height: 1.6; }
.wa-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 3px; }
.wa-new-panel { padding: 0; }
.wa-new-panel[open] { padding: 22px; }
.wa-new-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 22px; cursor: pointer; font-size: 14px; font-weight: 700; list-style: none; }
.wa-new-summary::-webkit-details-marker { display: none; }
.wa-new-summary .eyebrow { display: inline; margin-right: 6px; }
.wa-new-summary-hint { color: var(--muted); font-size: 11px; font-weight: 400; }
.wa-new-panel[open] .wa-new-summary { padding: 0 0 16px; }

/* WhatsApp: history resync action */
.wa-inline-form {
    display: inline-flex;
    margin: 0;
}
.wa-inline-form .btn {
    white-space: nowrap;
}

/* 邮箱工作台 */
.nav-badge[hidden], .mail-pop[hidden] { display: none; }
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 99px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    line-height: 1;
    vertical-align: middle;
}
.mail-shell {
    display: grid;
    grid-template-columns: 190px 340px minmax(0, 1fr) 300px;
    gap: 14px;
    align-items: start;
}
.mail-side, .mail-list, .mail-reading, .mail-customer {
    min-width: 0;
}
.mail-side, .mail-list, .mail-customer {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
}
.mail-side { padding: 14px; }
.mail-side-label {
    color: var(--dim);
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin: 0 0 8px 2px;
}
.mail-accounts { display: grid; gap: 5px; }
.mail-account {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--text);
    text-decoration: none;
}
.mail-account:hover { background: var(--hover); }
.mail-account.is-active { border-color: var(--blue-line); background: var(--blue-soft); }
.mail-account-avatar, .mail-customer-avatar, .mail-message-avatar {
    display: flex; align-items: center; justify-content: center;
    flex: none; border-radius: 8px; background: var(--blue-soft); color: var(--blue);
    font-weight: 700;
}
.mail-account-avatar { width: 30px; height: 30px; font-size: 12px; }
.mail-account-main { min-width: 0; flex: 1; }
.mail-account-name, .mail-account-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-account-name { font-size: 12px; font-weight: 600; }
.mail-account-email { margin-top: 2px; color: var(--dim); font-size: 10px; }
.mail-account-owner { margin-top: 2px; color: var(--muted); font-size: 10px; }
.mail-account-dot { width: 7px; height: 7px; flex: none; border-radius: 99px; background: var(--dim); }
.mail-account-dot.ok { background: var(--green); }
.mail-account-dot.warn { background: var(--warn-text); }
.mail-account-dot.danger { background: var(--red); }
.mail-folders { display: grid; gap: 2px; }
.mail-folder {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px; border-radius: 8px;
    color: var(--muted); text-decoration: none; font-size: 12px;
}
.mail-folder:hover { background: var(--hover); color: var(--text); }
.mail-folder.is-active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.mail-folder-count {
    min-width: 18px; padding: 2px 5px; border-radius: 99px;
    background: var(--blue); color: #fff; font-size: 10px; text-align: center;
}
.mail-side-footer { margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--line); }
.mail-sync-state { font-size: 11px; font-weight: 600; }
.mail-sync-state.ok { color: var(--green); }
.mail-sync-state.warn { color: var(--warn-text); }
.mail-sync-state.danger { color: var(--red); }
.mail-sync-time { margin-top: 3px; color: var(--dim); font-size: 10px; }
.mail-sync-error { margin-top: 6px; color: var(--red); font-size: 10px; line-height: 1.5; word-break: break-word; }

.mail-list { overflow: hidden; }
.mail-search { display: flex; gap: 6px; padding: 12px; border-bottom: 1px solid var(--line); }
.mail-search input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--text); padding: 7px 9px; font-size: 11px; }
.mail-list-head {
    display: flex; align-items: baseline; justify-content: space-between;
    padding: 12px 14px 10px; color: var(--dim); font-size: 11px;
}
.mail-list-head strong { color: var(--text); font-size: 13px; }
.mail-thread-list { display: grid; }
.mail-thread {
    display: block; padding: 11px 14px; border-top: 1px solid var(--line);
    color: var(--text); text-decoration: none; background: transparent;
}
.mail-thread:hover { background: var(--hover); }
.mail-thread.is-active { background: var(--blue-soft); border-left: 3px solid var(--blue); padding-left: 11px; }
.mail-thread.is-unread .mail-thread-subject { font-weight: 700; }
.mail-thread-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.mail-thread-people { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-thread-date { flex: none; color: var(--dim); font-size: 10px; }
.mail-thread-subject { margin-top: 3px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-thread-snippet { margin-top: 3px; color: var(--dim); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-thread-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--dim); font-size: 10px; }
.mail-unread { color: var(--red); font-weight: 600; }
.mail-customer-tag { color: var(--green); }
.mail-star { color: var(--warn-text); margin-right: 3px; }

.mail-reading { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); overflow: hidden; }
.mail-empty { border: 0; }
.mail-reading-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
    padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.mail-reading-head h2 { margin: 3px 0 4px; font-size: 18px; letter-spacing: -.02em; line-height: 1.35; }
.mail-reading-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; flex: none; }
.mail-reading-actions form { display: inline-flex; }
.mail-messages { display: grid; gap: 12px; padding: 14px; background: var(--panel-2); }
.mail-message { border: 1px solid var(--line); border-radius: 11px; background: var(--panel); overflow: hidden; }
.mail-message.is-outgoing { border-color: var(--blue-line); }
.mail-message-head { display: flex; align-items: center; gap: 9px; padding: 11px 13px; border-bottom: 1px solid var(--line); }
.mail-message-avatar { width: 32px; height: 32px; font-size: 12px; }
.mail-message-meta { min-width: 0; flex: 1; }
.mail-message-from { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-message-email { color: var(--dim); font-weight: 400; font-size: 10px; }
.mail-message-to { margin-top: 2px; color: var(--dim); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-message-tools { display: flex; gap: 4px; flex: none; }
.mail-body-frame { display: block; width: 100%; height: 360px; border: 0; background: #fff; }
.mail-body-text { padding: 14px 16px; white-space: pre-wrap; word-break: break-word; color: var(--text); font-size: 13px; line-height: 1.75; min-height: 100px; }
.mail-attachments { display: flex; flex-wrap: wrap; gap: 7px; padding: 10px 13px; border-top: 1px solid var(--line); background: var(--panel-2); }
.mail-attachment {
    display: flex; align-items: center; gap: 7px; max-width: 100%;
    padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px;
    color: var(--text); text-decoration: none; background: var(--panel);
}
.mail-attachment:hover { border-color: var(--blue-line); }
.mail-attachment-icon { flex: none; color: var(--blue); font-size: 9px; font-weight: 700; }
.mail-attachment strong { display: block; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.mail-attachment em { display: block; color: var(--dim); font-style: normal; font-size: 10px; }

.mail-customer { padding: 14px; }
.mail-customer-empty { color: var(--muted); font-size: 12px; line-height: 1.7; }
.mail-customer-empty p { margin: 8px 0 0; }
.mail-customer-card { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.mail-customer-top { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.mail-customer-avatar { width: 36px; height: 36px; font-size: 13px; }
.mail-customer-name { font-size: 13px; font-weight: 700; }
.mail-customer-sub { margin-top: 3px; color: var(--dim); font-size: 11px; line-height: 1.5; }
.mail-customer-section { margin-top: 14px; }
.mail-customer-section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; color: var(--dim); font-size: 10px; }
.mail-customer-section-head strong { color: var(--text); font-size: 12px; }
.mail-customer-empty-text { color: var(--dim); font-size: 11px; line-height: 1.7; }
.mail-order { display: block; margin-bottom: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); text-decoration: none; }
.mail-order:hover { border-color: var(--blue-line); background: var(--hover); }
.mail-order-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 11px; }
.mail-order-sub { margin-top: 3px; color: var(--dim); font-size: 10px; }
.mail-followup { padding: 7px 0; border-top: 1px dashed var(--line); font-size: 11px; line-height: 1.5; }
.mail-followup:first-child { border-top: 0; }
.mail-followup-meta { color: var(--dim); font-size: 10px; margin-bottom: 2px; }
.mail-compose-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
.mail-compose-grid .mail-customer { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.mail-draft-attachments { margin: 10px 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.mail-pop { border-color: var(--blue-line); }
.mail-pop .announcement-pop-eyebrow { color: var(--blue); }
@media (max-width: 1250px) {
    .mail-shell { grid-template-columns: 170px minmax(0, 1fr); }
    .mail-reading, .mail-customer { grid-column: 2; }
    .mail-customer { margin-top: 0; }
}
@media (max-width: 900px) {
    .mail-shell, .mail-compose-grid { grid-template-columns: 1fr; }
    .mail-side, .mail-list, .mail-reading, .mail-customer { grid-column: 1; }
    .mail-side { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
    .mail-side-footer { grid-column: 1 / -1; margin-top: 0; }
}
.mail-money-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    margin-bottom: 7px;
}
.mail-money-summary > div {
    padding: 6px;
    border-radius: 7px;
    background: var(--panel-2);
    text-align: center;
}
.mail-money-summary span { display: block; color: var(--dim); font-size: 9px; }
.mail-money-summary strong { display: block; margin-top: 2px; font-size: 11px; font-variant-numeric: tabular-nums; }
.mail-overdue { margin: 0 0 6px; color: var(--red); font-size: 10px; font-weight: 600; }
.mail-receivable {
    display: block;
    margin-bottom: 5px;
    padding: 7px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
}
.mail-receivable:hover { border-color: var(--blue-line); background: var(--hover); }
.mail-receivable-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 11px; }
.mail-receivable-sub { margin-top: 3px; color: var(--dim); font-size: 9px; line-height: 1.45; }
