:root {
  --ink: #17201b;
  --muted: #68726c;
  --muted-2: #8c958f;
  --line: #dfe4df;
  --line-soft: #edf0ed;
  --surface: #ffffff;
  --canvas: #f5f6f4;
  --green: #16734a;
  --green-hover: #105f3c;
  --green-soft: #e8f3ed;
  --amber: #a75c12;
  --amber-soft: #fff2df;
  --red: #b42318;
  --red-soft: #feeceb;
  --sidebar: #17201b;
  --shadow: 0 10px 28px rgba(23, 32, 27, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }
.mobile-only { display: none; }

.auth-view { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.15fr) minmax(420px, .85fr); background: var(--surface); }
.auth-brand { position: relative; overflow: hidden; padding: clamp(40px, 6vw, 88px); display: flex; flex-direction: column; justify-content: space-between; background: var(--sidebar); color: white; }
.auth-brand::after { content: ""; position: absolute; right: -110px; bottom: -140px; width: 420px; height: 420px; border: 1px solid rgba(255,255,255,.14); transform: rotate(15deg); }
.brand-mark { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; border-radius: 6px; color: white; background: var(--green); }
.brand-mark svg { width: 22px; height: 22px; }
.brand-mark-large { width: 54px; height: 54px; background: #eff8f3; color: var(--green); }
.brand-mark-large svg { width: 29px; height: 29px; }
.brand-kicker { margin: 0 0 12px; color: #99d1b5; font-size: 12px; font-weight: 800; letter-spacing: 1.5px; }
.auth-brand h1 { margin: 0; font-size: clamp(52px, 7vw, 84px); line-height: 1; font-family: "STKaiti", "KaiTi", serif; letter-spacing: 0; }
.auth-lead { margin: 22px 0 0; color: #cbd6cf; font-size: 18px; }
.auth-proof { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 12px 24px; color: #dce5df; font-size: 13px; }
.auth-proof span { display: flex; align-items: center; gap: 8px; }
.auth-proof svg { width: 17px; color: #78c69e; }
.auth-panel { display: grid; place-items: center; padding: 40px; }
.auth-box { width: min(100%, 390px); }
.auth-mobile-brand { display: none; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 30px; border-bottom: 1px solid var(--line); }
.auth-tab { border: 0; border-bottom: 2px solid transparent; padding: 13px; background: transparent; color: var(--muted); font-weight: 700; }
.auth-tab.active { color: var(--ink); border-bottom-color: var(--green); }
.auth-form { display: grid; gap: 19px; }
.form-field { display: grid; gap: 8px; }
.form-field label, .field-label { color: #39433d; font-size: 13px; font-weight: 700; }
input[type="text"], input[type="email"], input[type="password"] { width: 100%; height: 46px; padding: 0 13px; border: 1px solid #ccd3cd; border-radius: 6px; background: white; color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22,115,74,.12); }
.form-error { margin: 16px 0 0; padding: 11px 12px; border-radius: 6px; color: var(--red); background: var(--red-soft); font-size: 13px; }

.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 6px; padding: 0 15px; font-weight: 750; font-size: 13px; text-decoration: none; transition: background .15s, border-color .15s, transform .15s; }
.button:active { transform: translateY(1px); }
.button svg { width: 17px; height: 17px; }
.button-primary { background: var(--green); color: white; }
.button-primary:hover { background: var(--green-hover); }
.button-secondary { border-color: #cdd4ce; background: white; color: var(--ink); }
.button-secondary:hover { border-color: #9aa59d; background: #fafbfa; }
.button-danger { color: var(--red); background: white; border-color: #efc5c2; }
.button-quiet { background: transparent; color: var(--muted); }
.button-full { width: 100%; margin-top: 5px; height: 46px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; z-index: 20; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px 14px; background: var(--sidebar); color: white; }
.sidebar-brand { height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.sidebar-brand strong { display: block; font-size: 18px; }
.sidebar-brand small { display: block; margin-top: 2px; color: #94a39a; font-size: 10px; }
.nav-list { display: grid; gap: 5px; margin-top: 34px; }
.nav-item { position: relative; width: 100%; height: 43px; display: flex; align-items: center; gap: 11px; padding: 0 12px; border: 0; border-radius: 6px; color: #aebbb3; background: transparent; text-align: left; font-size: 13px; font-weight: 650; }
.nav-item svg { width: 18px; height: 18px; }
.nav-item:hover { color: white; background: #202d26; }
.nav-item.active { color: white; background: #29382f; }
.nav-item.active::before { content: ""; position: absolute; left: 0; width: 3px; height: 20px; border-radius: 0 2px 2px 0; background: #57b584; }
.nav-item b { margin-left: auto; padding: 3px 5px; border-radius: 4px; color: #ffd29d; background: #51351e; font-size: 9px; font-weight: 800; }
.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid #314038; }
.account-button { width: 100%; display: grid; grid-template-columns: 34px 1fr 16px; align-items: center; gap: 9px; padding: 8px; border: 0; color: white; background: transparent; text-align: left; }
.account-button > span:nth-child(2) { min-width: 0; }
.account-button strong, .account-button small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-button strong { font-size: 12px; }
.account-button small { margin-top: 3px; color: #87968d; font-size: 10px; }
.account-button svg { width: 15px; color: #79877f; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #173b29; background: #bde4cf; font-size: 12px; font-weight: 800; }
.logout-button { width: 100%; height: 36px; display: flex; align-items: center; gap: 9px; margin-top: 3px; padding: 0 10px; border: 0; color: #91a097; background: transparent; font-size: 11px; }
.logout-button:hover { color: white; }
.logout-button svg { width: 15px; }

.main-area { min-width: 0; }
.topbar { height: 78px; display: flex; align-items: center; padding: 0 clamp(22px, 4vw, 52px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); }
.topbar h2 { margin: 2px 0 0; font-size: 20px; line-height: 1.2; }
.topbar-eyebrow { margin: 0; color: var(--muted-2); font-size: 10px; font-weight: 800; }
.topbar-create { margin-left: auto; }
.page-content { width: min(100%, 1320px); margin: 0 auto; padding: 32px clamp(22px, 4vw, 52px) 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-head h3 { margin: 0; font-size: 23px; }
.page-head p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 30px 0 14px; }
.section-title h3 { margin: 0; font-size: 15px; }
.section-title a, .text-button { border: 0; padding: 0; color: var(--green); background: transparent; font-size: 12px; font-weight: 750; text-decoration: none; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-card { min-height: 112px; display: grid; grid-template-columns: 1fr auto; align-content: space-between; padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.metric-card p { margin: 0; color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin-top: 11px; font-size: 25px; }
.metric-icon { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 6px; background: var(--green-soft); color: var(--green); }
.metric-icon.amber { color: var(--amber); background: var(--amber-soft); }
.metric-icon.gray { color: #59655d; background: #eef1ee; }
.metric-icon svg { width: 18px; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, .7fr); gap: 20px; }
.activity-panel, .quick-panel { border: 1px solid var(--line); border-radius: 7px; background: white; }
.activity-panel { min-width: 0; overflow: hidden; }
.quick-panel { padding: 18px; }
.quick-panel h3 { margin: 0 0 14px; font-size: 14px; }
.quick-action { width: 100%; min-height: 70px; display: grid; grid-template-columns: 38px 1fr 18px; align-items: center; gap: 11px; padding: 12px 4px; border: 0; border-top: 1px solid var(--line-soft); background: transparent; text-align: left; }
.quick-action:first-of-type { border-top: 0; }
.quick-action .metric-icon { width: 36px; height: 36px; }
.quick-action strong, .quick-action small { display: block; }
.quick-action strong { font-size: 12px; }
.quick-action small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.quick-action > svg { width: 16px; color: #9ba49e; }

.record-table { width: 100%; border-collapse: collapse; }
.record-table th { height: 40px; padding: 0 16px; color: var(--muted-2); background: #fafbfa; text-align: left; font-size: 10px; font-weight: 800; }
.record-table td { height: 66px; padding: 9px 16px; border-top: 1px solid var(--line-soft); font-size: 12px; }
.record-title { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.record-thumb { width: 42px; height: 42px; flex: 0 0 42px; border: 1px solid var(--line); border-radius: 5px; object-fit: cover; background: #f2f4f2; }
.record-title strong, .record-title small { display: block; }
.record-title strong { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-title small { margin-top: 4px; color: var(--muted-2); font-size: 10px; }
.status { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border-radius: 4px; color: var(--green); background: var(--green-soft); font-size: 10px; font-weight: 800; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.paused { color: var(--amber); background: var(--amber-soft); }
.table-action { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: white; }
.table-action svg { width: 15px; }

.tool-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); gap: 24px; align-items: start; }
.tool-main { padding: 24px; border: 1px solid var(--line); border-radius: 7px; background: white; }
.tool-main h3, .tool-aside h3 { margin: 0 0 20px; font-size: 15px; }
.tool-main form { display: grid; gap: 20px; }
.dropzone { position: relative; min-height: 310px; display: grid; place-items: center; overflow: hidden; border: 1.5px dashed #aab4ad; border-radius: 7px; background: #fafbfa; transition: border .15s, background .15s; }
.dropzone:hover, .dropzone.dragging { border-color: var(--green); background: #f4faf6; }
.dropzone input { position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone-content { display: grid; justify-items: center; padding: 30px; text-align: center; }
.dropzone-content .upload-icon { width: 45px; height: 45px; display: grid; place-items: center; margin-bottom: 14px; border-radius: 50%; color: var(--green); background: var(--green-soft); }
.dropzone-content .upload-icon svg { width: 21px; }
.dropzone-content strong { font-size: 13px; }
.dropzone-content small { margin-top: 7px; color: var(--muted); font-size: 11px; }
.dropzone-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 12px; background: #f0f2f0; }
.file-chip { position: absolute; z-index: 2; right: 12px; bottom: 12px; max-width: calc(100% - 24px); padding: 7px 9px; border-radius: 5px; color: white; background: rgba(23,32,27,.86); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-actions { display: flex; justify-content: flex-end; gap: 10px; }
.tool-aside { padding: 22px; border-left: 3px solid var(--green); background: #edf5f0; }
.tool-aside ol { margin: 0; padding: 0; list-style: none; counter-reset: steps; }
.tool-aside li { position: relative; min-height: 54px; padding: 0 0 18px 39px; color: #48534c; font-size: 12px; line-height: 1.6; }
.tool-aside li::before { counter-increment: steps; content: counter(steps); position: absolute; left: 0; top: 0; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--green); font-size: 10px; font-weight: 800; }
.tool-aside li:not(:last-child)::after { content: ""; position: absolute; left: 11px; top: 27px; bottom: 3px; width: 1px; background: #b9d8c7; }
.tool-note { display: flex; gap: 9px; margin-top: 7px; padding: 12px; border: 1px solid #d7c39f; border-radius: 6px; color: #6a4a24; background: #fff8ea; font-size: 11px; line-height: 1.55; }
.tool-note svg { width: 16px; flex: 0 0 16px; }

.filterbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.searchbox { position: relative; width: min(360px, 100%); }
.searchbox svg { position: absolute; left: 12px; top: 12px; width: 16px; color: var(--muted); }
.searchbox input { padding-left: 38px; }
.record-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.record-card { overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: white; }
.record-card-image { position: relative; aspect-ratio: 16 / 10; background: #eef1ee; overflow: hidden; }
.record-card-image img { width: 100%; height: 100%; object-fit: cover; }
.record-card-image .status { position: absolute; left: 10px; top: 10px; }
.record-card-body { padding: 14px; }
.record-card-body h4 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.record-card-meta { display: flex; justify-content: space-between; margin: 8px 0 13px; color: var(--muted); font-size: 10px; }
.record-card-actions { display: flex; gap: 7px; }
.record-card-actions .button { min-width: 0; flex: 1; padding: 0 8px; }

.empty-state { min-height: 290px; display: grid; place-items: center; padding: 40px; border: 1px dashed #bcc5bf; border-radius: 7px; background: white; text-align: center; }
.empty-state-icon { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 50%; color: var(--green); background: var(--green-soft); }
.empty-state h3 { margin: 0; font-size: 15px; }
.empty-state p { margin: 8px 0 18px; color: var(--muted); font-size: 12px; }

.detail-head { display: flex; align-items: center; gap: 13px; margin-bottom: 20px; }
.detail-head .icon-button { flex: 0 0 auto; }
.detail-head h3 { margin: 0; font-size: 20px; }
.detail-head p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: white; }
.icon-button svg { width: 18px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); gap: 20px; }
.content-preview { min-height: 520px; display: grid; place-items: center; padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: #e9ece9; }
.content-preview img { max-height: 650px; object-fit: contain; box-shadow: var(--shadow); }
.detail-side { display: grid; gap: 14px; align-content: start; }
.detail-panel { padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: white; }
.detail-panel h4 { margin: 0 0 14px; font-size: 13px; }
.qr-preview { width: min(100%, 190px); margin: 0 auto 14px; border: 1px solid var(--line); }
.public-link { display: flex; gap: 6px; }
.public-link input { min-width: 0; height: 38px; color: var(--muted); font-size: 10px; }
.public-link .icon-button { width: 38px; height: 38px; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.replace-field { position: relative; }
.replace-field input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.metadata-list { display: grid; gap: 10px; margin: 0; }
.metadata-row { display: flex; justify-content: space-between; gap: 20px; font-size: 11px; }
.metadata-row dt { color: var(--muted); }
.metadata-row dd { margin: 0; font-weight: 700; text-align: right; }
.history-list { display: grid; gap: 8px; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line-soft); font-size: 10px; color: var(--muted); }
.history-item button { border: 0; color: var(--green); background: transparent; font-weight: 700; }
.toast-region { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { min-width: 260px; max-width: 360px; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 6px; background: white; box-shadow: var(--shadow); font-size: 12px; animation: toast-in .2s ease; }
.toast.error { border-left-color: var(--red); }
.toast svg { width: 17px; color: var(--green); }
.toast.error svg { color: var(--red); }
.loading { min-height: 300px; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.spinner { width: 24px; height: 24px; border: 2px solid #dce3de; border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .record-grid { grid-template-columns: repeat(2, 1fr); }
  .overview-grid, .tool-layout, .detail-grid { grid-template-columns: 1fr; }
  .tool-aside { order: -1; }
  .content-preview { min-height: 400px; }
}

@media (max-width: 760px) {
  .mobile-only { display: grid; }
  .auth-view { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-panel { min-height: 100vh; padding: 24px; }
  .auth-mobile-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 32px; }
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: min(280px, 86vw); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; z-index: 15; inset: 0; display: block; background: rgba(12,18,14,.46); }
  .topbar { height: 70px; padding: 0 16px; gap: 12px; }
  .topbar h2 { font-size: 17px; }
  .topbar-create span { display: none; }
  .topbar-create { width: 40px; padding: 0; }
  .page-content { padding: 23px 16px 44px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric-card { min-height: 100px; padding: 14px; }
  .metric-card strong { font-size: 21px; }
  .record-table th:nth-child(3), .record-table td:nth-child(3), .record-table th:nth-child(4), .record-table td:nth-child(4) { display: none; }
  .record-grid { grid-template-columns: 1fr; }
  .tool-main { padding: 16px; }
  .dropzone { min-height: 260px; }
  .tool-actions { flex-direction: column-reverse; }
  .tool-actions .button { width: 100%; }
  .detail-actions { grid-template-columns: 1fr; }
  .content-preview { min-height: 300px; padding: 10px; }
}
