:root {
  --green-950: #12392d;
  --green-900: #173f32;
  --green-700: #286348;
  --green-100: #eaf3ed;
  --red: #d7434e;
  --red-dark: #bd303c;
  --cream: #f5f4ef;
  --white: #fff;
  --ink: #19382e;
  --muted: #687a72;
  --border: #dfe6e1;
  --shadow: 0 16px 40px rgba(21, 56, 44, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
:focus-visible { outline: 3px solid rgba(215, 67, 78, .28); outline-offset: 2px; }
.skip-link { position: fixed; z-index: 100; top: -80px; left: 16px; padding: 10px 14px; border-radius: 8px; color: #fff; background: var(--green-950); }
.skip-link:focus { top: 12px; }
.eyebrow, .topbar-kicker { margin: 0; color: var(--red); font-size: 11px; font-weight: 800; letter-spacing: .18em; }
.muted { color: var(--muted); }

.login-view { display: grid; min-height: 100vh; grid-template-columns: minmax(440px, 1.15fr) minmax(420px, .85fr); }
.login-visual { position: relative; display: flex; min-height: 680px; flex-direction: column; overflow: hidden; padding: 44px 6vw; color: #fff; background: linear-gradient(145deg, rgba(16,57,43,.92), rgba(16,57,43,.68)), url('/uploads/watermelon-field.webp') center/cover; }
.login-brand, .mobile-brand { display: flex; align-items: center; gap: 13px; font-size: 18px; font-weight: 800; letter-spacing: .12em; }
.brand-symbol { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.5); border-radius: 50%; }
.brand-symbol i { width: 22px; height: 22px; border: 5px solid #f0f5f1; border-radius: 50%; background: var(--red); }
.login-message { position: relative; z-index: 2; max-width: 650px; margin: auto 0; }
.login-message .eyebrow { color: #f0bab8; }
.login-message h1 { margin: 20px 0 24px; font-size: clamp(42px, 4.2vw, 68px); line-height: 1.18; letter-spacing: -.04em; }
.login-message > p:last-child { max-width: 520px; color: rgba(255,255,255,.76); font-size: 17px; line-height: 1.8; }
.field-lines { position: absolute; right: -14%; bottom: -18%; left: -12%; height: 45%; transform: rotate(-8deg); }
.field-lines i { display: block; height: 18%; margin-top: 2%; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 44px; background: #fbfbf8; }
.login-card { width: min(100%, 420px); padding: 38px; border: 1px solid var(--border); border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.mobile-brand { display: none; margin-bottom: 42px; color: var(--green-900); }
.mobile-brand .brand-symbol { border-color: #cbd9d0; }
.mobile-brand .brand-symbol i { border-color: var(--green-900); }
.login-card h2 { margin: 12px 0 8px; font-size: 34px; letter-spacing: -.03em; }
.login-card > .muted { margin: 0 0 30px; }
.field { display: grid; gap: 8px; margin-top: 18px; color: #334e44; font-size: 13px; font-weight: 700; }
.field input, .field textarea { width: 100%; border: 1px solid #ccd8d1; border-radius: 10px; color: var(--ink); background: #fff; transition: border-color .2s, box-shadow .2s; }
.field input { height: 44px; padding: 0 13px; }
.field textarea { min-height: 105px; padding: 12px 13px; line-height: 1.6; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px rgba(40,99,72,.11); outline: none; }
.form-error { min-height: 20px; margin: 12px 0 4px; color: #b52d37; font-size: 13px; }
.primary-button, .secondary-button, .danger-button, .upload-button, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border-radius: 10px; font-weight: 750; transition: color .2s, background .2s, border-color .2s, box-shadow .2s; }
.primary-button { padding: 0 18px; border: 1px solid var(--red); color: #fff; background: var(--red); box-shadow: 0 8px 18px rgba(215,67,78,.18); }
.primary-button:hover { border-color: var(--red-dark); background: var(--red-dark); }
.primary-button svg, .logout-button svg { width: 18px; height: 18px; fill: currentColor; }
.full-button { width: 100%; height: 48px; }

.admin-view { min-height: 100vh; }
.sidebar { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; display: flex; width: 252px; flex-direction: column; padding: 28px 18px 20px; color: rgba(255,255,255,.75); background: var(--green-950); }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 28px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-symbol.small { width: 40px; height: 40px; flex: 0 0 auto; }
.sidebar-brand div { display: flex; min-width: 0; flex-direction: column; }
.sidebar-brand strong { color: #fff; font-size: 17px; letter-spacing: .08em; }
.sidebar-brand span:last-child { margin-top: 3px; color: rgba(255,255,255,.48); font-size: 11px; }
.sidebar nav { display: grid; gap: 6px; margin-top: 30px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 12px 13px; border-radius: 10px; color: inherit; font-size: 14px; font-weight: 650; text-decoration: none; transition: color .2s, background .2s; }
.nav-link svg { width: 19px; height: 19px; fill: currentColor; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-link.active { color: #fff; background: rgba(255,255,255,.12); box-shadow: inset 3px 0 0 #ed6a70; }
.logout-button { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 12px 13px; border: 0; border-radius: 9px; color: rgba(255,255,255,.65); background: transparent; }
.logout-button:hover { color: #fff; background: rgba(255,255,255,.07); }
.workspace { min-height: 100vh; margin-left: 252px; }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; min-height: 86px; align-items: center; gap: 18px; padding: 14px clamp(22px, 3vw, 42px); border-bottom: 1px solid var(--border); background: rgba(251,251,248,.94); backdrop-filter: blur(16px); }
.topbar h1 { margin: 4px 0 0; font-size: 22px; letter-spacing: -.02em; }
.topbar-actions { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.dirty-status { color: #74837c; font-size: 12px; }
.dirty-status.unsaved { color: #a76a15; }
.menu-button { display: none; width: 42px; padding: 0; border: 1px solid var(--border); background: #fff; }
.menu-button svg { width: 22px; height: 22px; fill: currentColor; }
.main-content { max-width: 1280px; margin: 0 auto; padding: 34px clamp(22px, 3vw, 42px) 80px; }
.loading-state { display: grid; min-height: 50vh; place-content: center; justify-items: center; color: var(--muted); }
.loading-state span { width: 34px; height: 34px; border: 3px solid #dce5df; border-top-color: var(--green-700); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.editor-section { scroll-margin-top: 110px; margin-bottom: 60px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-head h2 { margin: 0; font-size: 26px; letter-spacing: -.03em; }
.section-head p { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.section-number { color: #cfd8d2; font: italic 38px Georgia, serif; }
.panel { padding: 26px; border: 1px solid var(--border); border-radius: 18px; background: #fff; box-shadow: 0 8px 30px rgba(21,56,44,.04); }
.panel + .panel { margin-top: 18px; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.panel-title { margin: 0; font-size: 17px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 20px; }
.field.wide { grid-column: 1 / -1; }
.media-field { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 24px; align-items: center; }
.media-preview { position: relative; display: grid; min-height: 150px; overflow: hidden; place-items: center; border: 1px solid var(--border); border-radius: 14px; color: var(--muted); background: #eef3ef; }
.media-preview img, .media-preview video { width: 100%; height: 170px; object-fit: cover; }
.media-actions { display: grid; gap: 10px; align-content: center; }
.upload-button, .secondary-button { padding: 0 15px; border: 1px solid #c8d6cd; color: var(--green-700); background: #fff; }
.upload-button:hover, .secondary-button:hover { border-color: var(--green-700); background: var(--green-100); }
.upload-hint { margin: 0; color: #7e8e86; font-size: 12px; line-height: 1.5; }
.list-stack { display: grid; gap: 15px; }
.item-card { position: relative; padding: 20px; border: 1px solid var(--border); border-radius: 14px; background: #fbfcfa; }
.item-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.item-index { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; color: #fff; background: var(--green-700); font-size: 12px; font-weight: 800; }
.item-head strong { font-size: 14px; }
.item-tools { display: flex; gap: 5px; margin-left: auto; }
.icon-button { width: 34px; min-height: 34px; padding: 0; border: 1px solid var(--border); color: #62756b; background: #fff; }
.icon-button:hover { border-color: #a9bbb0; color: var(--green-900); }
.icon-button.danger:hover { border-color: #e8b8bc; color: #b72c36; background: #fff4f4; }
.icon-button svg { width: 17px; height: 17px; fill: currentColor; }
.item-media-grid { display: grid; grid-template-columns: 180px 1fr; gap: 18px; }
.item-media-grid .media-preview { min-height: 125px; }
.item-media-grid .media-preview img { height: 135px; }
.add-button { width: 100%; margin-top: 14px; border-style: dashed; }
.metric-admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.metric-admin-grid .item-card { min-width: 0; }
.score-row { display: grid; grid-template-columns: 1fr 110px; gap: 16px; }
.overview-hero { display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; }
.overview-card { min-height: 170px; }
.overview-card.primary { position: relative; overflow: hidden; color: #fff; background: var(--green-900); }
.overview-card.primary::after { position: absolute; right: -50px; bottom: -110px; width: 260px; height: 180px; border: 24px solid rgba(255,255,255,.06); border-radius: 50%; content: ''; }
.overview-label { color: rgba(255,255,255,.6); font-size: 12px; font-weight: 800; letter-spacing: .14em; }
.overview-card h2 { position: relative; z-index: 2; margin: 20px 0 12px; font-size: 30px; }
.overview-card p { position: relative; z-index: 2; max-width: 580px; margin: 0; color: rgba(255,255,255,.7); line-height: 1.7; }
.overview-stat { display: flex; height: 100%; flex-direction: column; justify-content: center; }
.overview-stat strong { margin: 10px 0 5px; color: var(--green-900); font: italic 48px Georgia, serif; }
.overview-stat span { color: var(--muted); font-size: 13px; }
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-top: 18px; }
.quick-card { padding: 20px; border: 1px solid var(--border); border-radius: 15px; color: inherit; background: #fff; text-decoration: none; transition: border-color .2s, box-shadow .2s; }
.quick-card:hover { border-color: #b5c8bc; box-shadow: var(--shadow); }
.quick-card span { color: var(--red); font: italic 16px Georgia, serif; }
.quick-card h3 { margin: 20px 0 6px; font-size: 15px; }
.quick-card p { margin: 0; color: var(--muted); font-size: 12px; }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: 360px; padding: 13px 17px; border-radius: 10px; color: #fff; background: #214c3a; box-shadow: 0 14px 36px rgba(13,38,28,.24); opacity: 0; pointer-events: none; transform: translateY(16px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #b7333d; }
.upload-progress { position: fixed; z-index: 110; right: 24px; bottom: 24px; width: min(430px, calc(100vw - 32px)); padding: 18px; border: 1px solid #d9e3dc; border-radius: 15px; background: #fff; box-shadow: 0 20px 55px rgba(13,38,28,.2); }
.upload-progress-head { display: flex; align-items: center; gap: 12px; }
.upload-file-icon { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border-radius: 11px; color: var(--green-700); background: var(--green-100); }
.upload-file-icon svg { width: 22px; height: 22px; fill: currentColor; }
.upload-progress-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.upload-progress-copy strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.upload-progress-copy span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.upload-progress-percent { color: var(--green-700); font-size: 16px; font-variant-numeric: tabular-nums; }
.upload-progress-track { height: 8px; margin-top: 16px; overflow: hidden; border-radius: 5px; background: #e7ede9; }
.upload-progress-bar { width: 0; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--green-700), #43a16f); transition: width .12s linear; }
.upload-progress-meta { display: flex; justify-content: space-between; gap: 16px; margin-top: 9px; color: #718078; font-size: 11px; font-variant-numeric: tabular-nums; }
.upload-progress.upload-error .upload-file-icon { color: #b7333d; background: #fff0f1; }
.upload-progress.upload-error .upload-progress-bar { background: #c83b46; }
.upload-progress.upload-error .upload-progress-percent { color: #b7333d; }
.sidebar-mask { display: none; }

@media (max-width: 980px) {
  .login-view { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { min-height: 100vh; }
  .mobile-brand { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .admin-view.sidebar-open .sidebar { transform: translateX(0); }
  .workspace { margin-left: 0; }
  .menu-button { display: inline-flex; }
  .sidebar-mask { position: fixed; z-index: 25; inset: 0; background: rgba(7,25,18,.4); }
  .admin-view.sidebar-open .sidebar-mask { display: block; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .login-panel { padding: 20px; }
  .login-card { padding: 28px 22px; }
  .topbar { align-items: center; padding: 12px 16px; }
  .topbar-kicker, .dirty-status { display: none; }
  .topbar h1 { font-size: 18px; }
  .topbar .primary-button { width: 44px; padding: 0; font-size: 0; }
  .main-content { padding: 24px 16px 60px; }
  .section-head h2 { font-size: 23px; }
  .panel { padding: 20px 16px; }
  .field-grid, .metric-admin-grid, .overview-hero, .score-row { grid-template-columns: 1fr; }
  .field.wide { grid-column: auto; }
  .media-field, .item-media-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: 1fr; }
  .media-preview img, .media-preview video { height: 190px; }
  .upload-progress { right: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
