:root {
  --green: #1f7a53;
  --green-dark: #145c3e;
  --green-light: #eaf5ef;
  --ink: #1f2a24;
  --muted: #6b7a71;
  --line: #e4eae6;
  --bg: #f4f6f4;
  --sidebar: #163a2b;
  --danger: #c0392b;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.65;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
p { margin: 0; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }

/* ---------- layout ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 228px; flex-shrink: 0; background: linear-gradient(180deg, #17402f, #102c20);
  color: #cfe3d7; position: fixed; inset: 0 auto 0 0; z-index: 40;
  display: flex; flex-direction: column;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-brand .mark { width: 38px; height: 38px; border-radius: 11px; background: rgba(255,255,255,.12); display: flex; align-items: center; justify-content: center; font-size: 19px; color: #fff; font-family: "STKaiti", "KaiTi", serif; }
.side-brand strong { color: #fff; font-size: 16px; letter-spacing: 1px; display: block; }
.side-brand span { font-size: 11px; color: #8fae9f; }
.side-nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.side-nav .group { font-size: 11px; color: #78998a; padding: 14px 12px 6px; letter-spacing: 1px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 10px 13px; border-radius: 9px; color: #c3d8cc; font-size: 14px; margin-bottom: 3px; transition: all .16s; }
.side-nav a svg { width: 18px; height: 18px; opacity: .8; }
.side-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-nav a.active { background: rgba(255,255,255,.13); color: #fff; font-weight: 600; }
.side-foot { padding: 14px 18px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #7d9c8d; }

.admin-main { flex: 1; margin-left: 228px; min-width: 0; }
.admin-topbar {
  height: 64px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 0 26px; position: sticky; top: 0; z-index: 30;
}
.admin-topbar h1 { font-size: 18px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-actions .who { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.topbar-actions svg { width: 16px; height: 16px; }
.admin-content { padding: 24px 26px 40px; }
.side-toggle { display: none; border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 38px; height: 34px; cursor: pointer; color: var(--ink); }

/* ---------- cards / stats ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 4px 16px rgba(26,54,40,.03); }
.card-pad { padding: 22px 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2 { font-size: 16px; }
.card-head .sub { font-size: 12.5px; color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; position: relative; overflow: hidden; }
.stat-card .label { font-size: 13px; color: var(--muted); }
.stat-card .value { font-size: 30px; font-weight: 700; margin-top: 8px; letter-spacing: .5px; }
.stat-card .ic { position: absolute; right: 16px; top: 18px; width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; background: var(--green-light); color: var(--green); }
.stat-card .ic svg { width: 21px; height: 21px; }
.stat-card:nth-child(2) .ic { background: #eef5fb; color: #2c5f8a; }
.stat-card:nth-child(3) .ic { background: #fff3e6; color: #c9792c; }
.stat-card:nth-child(4) .ic { background: #f0ecfa; color: #6b52a3; }
.stat-card .foot { margin-top: 10px; font-size: 12px; color: #95a49b; }
.dash-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; margin-top: 20px; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.search-box { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 4px 6px 4px 12px; }
.search-box input { border: none; outline: none; background: none; font-size: 13.5px; width: 220px; padding: 6px 0; font-family: inherit; }
.search-box button { border: none; background: var(--green); color: #fff; border-radius: 7px; padding: 6px 14px; cursor: pointer; font-size: 13px; }
.search-box .clear { font-size: 12.5px; color: var(--muted); padding-right: 6px; }
.search-box .clear:hover { color: var(--danger); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; border-radius: 9px; padding: 9px 18px; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: all .16s; white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-outline { background: #fff; border: 1px solid #cfdcd4; color: #40524a; }
.btn-outline:hover { border-color: #9fc5b1; color: var(--green); }
.btn-danger { background: #fdf0ee; color: var(--danger); border: 1px solid #f3d4cf; }
.btn-danger:hover { background: #fbe3df; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn-link { background: none; border: none; color: var(--green); padding: 0; font-size: 13px; cursor: pointer; font-weight: 600; }
.btn-link.danger { color: var(--danger); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12.5px; color: #7d8d84; font-weight: 600; background: #f8faf8; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid #eef2f0; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fbfcfb; }
.table .title-cell { max-width: 380px; }
.table .title-cell a { font-weight: 600; }
.table .title-cell a:hover { color: var(--green); }
.table .actions { display: flex; gap: 10px; align-items: center; white-space: nowrap; }
.table .actions form { display: inline; }
.thumb { width: 64px; height: 44px; border-radius: 7px; object-fit: cover; background: #eef2ef; }
.empty-row { text-align: center; color: #9aa8a0; padding: 44px 0 !important; }

/* ---------- badges ---------- */
.tag { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 6px; line-height: 1.6; white-space: nowrap; }
.tag-property { background: #eaf1fb; color: #2c5f8a; }
.tag-committee { background: var(--green-light); color: var(--green-dark); }
.tag-service { background: #fff3e6; color: #ad5c1d; }
.tag-pin { background: #fdecea; color: #c0392b; font-weight: 600; }
.badge { display: inline-flex; align-items: center; font-size: 12px; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.badge-open { background: var(--green-light); color: var(--green-dark); }
.badge-done { background: #eef1ef; color: #7b8a81; }
.badge-warn { background: #fff3e6; color: #ad5c1d; }

/* ---------- forms ---------- */
.admin-form { padding: 24px 26px 30px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; color: #4b5a52; font-weight: 600; }
.field label .req { color: #d3543f; margin-left: 3px; }
.field label .opt { color: #9aa8a0; font-weight: 400; margin-left: 4px; font-size: 12px; }
.field input[type=text], .field input[type=password], .field input[type=number], .field input[type=date], .field input[type=datetime-local], .field input[type=tel], .field input[type=url], .field select, .field textarea {
  width: 100%; border: 1px solid #d8e2dc; background: #fbfcfb; border-radius: 10px;
  padding: 10px 13px; font-size: 14px; color: var(--ink); font-family: inherit; transition: border-color .16s, box-shadow .16s;
}
.field textarea { resize: vertical; min-height: 150px; line-height: 1.8; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: #7ab99a; box-shadow: 0 0 0 3px rgba(31,122,83,.1); background: #fff; }
.field .tip { font-size: 12px; color: #93a198; }
.field input[type=file] { font-size: 13px; color: #56655c; background: #fbfcfb; border: 1px dashed #cbdcd2; border-radius: 10px; padding: 10px 12px; width: 100%; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: #46564d; min-height: 38px; }
.check-row input { accent-color: var(--green); width: 16px; height: 16px; }
.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.form-note { font-size: 12.5px; color: #93a198; }

/* ---------- gallery ---------- */
.gallery-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.gallery-item { position: relative; width: 150px; }
.gallery-item img { width: 150px; height: 100px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); }
.gallery-item form { position: absolute; top: 6px; right: 6px; }
.gallery-item .del { width: 24px; height: 24px; border-radius: 50%; border: none; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 13px; line-height: 1; }
.gallery-item .del:hover { background: var(--danger); }
.cover-preview { margin-top: 8px; width: 220px; border-radius: 9px; border: 1px solid var(--line); }

/* ---------- options editor ---------- */
.option-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.option-row input[type=text] { flex: 1; border: 1px solid #d8e2dc; background: #fbfcfb; border-radius: 9px; padding: 10px 13px; font-size: 14px; font-family: inherit; }
.option-row .order { width: 26px; height: 26px; border-radius: 50%; background: var(--green-light); color: var(--green-dark); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.option-row .remove { border: 1px solid #f0d5d0; background: #fdf5f4; color: var(--danger); border-radius: 8px; padding: 7px 11px; cursor: pointer; font-size: 12.5px; }
.option-hint { font-size: 12px; color: #93a198; margin-top: 4px; }

/* ---------- pagination ---------- */
.pager-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 16px 22px; border-top: 1px solid var(--line); }
.pager { display: flex; gap: 5px; flex-wrap: wrap; }
.pager a, .pager span { min-width: 32px; height: 32px; padding: 0 9px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 13px; color: #4f5e55; }
.pager a:hover { border-color: #a9cdb9; color: var(--green); }
.pager .current { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.pager .disabled { color: #c2ccc6; }
.page-jump { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.page-jump input { width: 56px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; text-align: center; font-family: inherit; }
.page-jump button { border: 1px solid #cfdcd4; background: #fff; border-radius: 7px; padding: 6px 12px; cursor: pointer; font-size: 12.5px; }
.page-jump button:hover { border-color: #9fc5b1; color: var(--green); }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(135deg, #123528, #1f7a53 60%, #3f9c6d); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 18px; padding: 36px 34px 32px; box-shadow: 0 26px 60px rgba(8,30,20,.28); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-brand .mark { width: 46px; height: 46px; border-radius: 13px; background: linear-gradient(135deg, var(--green), #3f9c6d); color: #fff; font-size: 22px; display: flex; align-items: center; justify-content: center; font-family: "STKaiti", "KaiTi", serif; }
.login-brand strong { font-size: 19px; letter-spacing: 2px; display: block; }
.login-brand span { font-size: 11px; color: #8a9a91; letter-spacing: 1px; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .desc { font-size: 13px; color: var(--muted); margin-bottom: 22px; }
.login-card .field { margin-bottom: 16px; }
.login-card .field input { width: 100%; border: 1px solid #d8e2dc; background: #fbfcfb; border-radius: 10px; padding: 11px 14px; font-size: 14.5px; font-family: inherit; }
.login-card .field input:focus { outline: none; border-color: #7ab99a; box-shadow: 0 0 0 3px rgba(31,122,83,.1); background: #fff; }
.captcha-row { display: flex; gap: 10px; align-items: stretch; }
.captcha-row input { flex: 1; }
.captcha-row img { width: 132px; height: 44px; border-radius: 9px; border: 1px solid #d8e2dc; cursor: pointer; }
.login-btn { width: 100%; border: none; border-radius: 10px; background: var(--green); color: #fff; padding: 12px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 6px; }
.login-btn:hover { background: var(--green-dark); }
.login-foot { margin-top: 18px; font-size: 12px; color: #9aa8a0; text-align: center; }
.login-alert { background: #fdf0ee; border: 1px solid #f3d4cf; color: #a8342a; border-radius: 9px; padding: 10px 13px; font-size: 13px; margin-bottom: 16px; }

/* ---------- dashboard lists ---------- */
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table td { padding: 10px 4px; border-bottom: 1px dashed var(--line); }
.mini-table tr:last-child td { border-bottom: none; }
.mini-table .time { color: #93a198; font-size: 12px; white-space: nowrap; text-align: right; }
.quick-links { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 18px 22px; }
.quick-links a { border: 1px solid var(--line); border-radius: 10px; padding: 13px 15px; display: flex; align-items: center; gap: 10px; font-size: 13.5px; transition: all .16s; }
.quick-links a:hover { border-color: #a9cdb9; background: var(--green-light); color: var(--green-dark); }
.quick-links svg { width: 18px; height: 18px; color: var(--green); }

/* ---------- flash ---------- */
.flash-stack { position: fixed; right: 24px; top: 80px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.flash { display: flex; align-items: flex-start; gap: 9px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 9px; padding: 12px 15px; box-shadow: 0 12px 30px rgba(20,40,30,.14); font-size: 13.5px; animation: slideIn .3s ease; }
.flash.error { border-left-color: var(--danger); }
.flash svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 2px; color: var(--green); }
.flash.error svg { color: var(--danger); }
@keyframes slideIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .admin-main { margin-left: 0; }
  .side-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .admin-content { padding: 18px 16px 32px; }
  .admin-topbar { padding: 0 16px; }
  .admin-topbar h1 { font-size: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-card .value { font-size: 24px; }
  .search-box input { width: 150px; }
}
