/* Kin Shing CMS — admin styles */
:root {
  --green: #227700;
  --green-700: #175300;
  --green-50: #f1f7ea;
  --ink: #14201a;
  --ink-soft: #2f3b34;
  --muted: #66756b;
  --line: #e3e8df;
  --line-strong: #cfd8c9;
  --bg: #f5f7f2;
  --paper: #fff;
  --danger: #b3261e;
  --radius: 6px;
  --font: "Helvetica Neue", "PingFang HK", "Microsoft JhengHei", "Noto Sans TC", system-ui, -apple-system, sans-serif;
  --mono: "SFMono-Regular", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.65;
  color: var(--ink-soft); background: var(--bg); -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; color: var(--ink); letter-spacing: -.01em; font-weight: 600; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }
code.code { font-family: var(--mono); font-size: 12px; background: #f2f5ee; padding: 2px 6px; border-radius: 3px; color: var(--muted); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.ta-r { text-align: right; }

.icon { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 244px; flex: none; background: #0d2b06; color: rgba(255, 255, 255, .72);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar__brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.sidebar__mark {
  width: 38px; height: 38px; border-radius: 4px; background: #fff; color: #0d2b06;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; letter-spacing: .04em;
}
.sidebar__brand strong { display: block; color: #fff; font-size: 14.5px; letter-spacing: .02em; }
.sidebar__brand small { display: block; font-size: 10.5px; color: rgba(255, 255, 255, .45); letter-spacing: .04em; }
.sidebar__nav { padding: 14px 12px; overflow-y: auto; flex: 1; }
.sidebar__nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 5px;
  font-size: 13.5px; color: rgba(255, 255, 255, .72); margin-bottom: 2px;
  transition: background .18s, color .18s;
}
.sidebar__nav a .icon { width: 17px; height: 17px; opacity: .7; }
.sidebar__nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar__nav a.is-active { background: #1f5f04; color: #fff; }
.sidebar__nav a.is-active .icon { opacity: 1; }
.sidebar__divider { height: 1px; background: rgba(255, 255, 255, .08); margin: 12px 6px; }
.badge { margin-left: auto; background: #e8f5c8; color: #23400a; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 100px; font-style: normal; }
.sidebar__foot { padding: 14px 16px 18px; border-top: 1px solid rgba(255, 255, 255, .08); display: grid; gap: 4px; }
.sidebar__foot a, .sidebar__foot .linkbtn {
  display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 4px;
  font-size: 12.5px; color: rgba(255, 255, 255, .6); background: none; border: 0; width: 100%; text-align: left;
}
.sidebar__foot a:hover, .sidebar__foot .linkbtn:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.sidebar__foot .icon { width: 15px; height: 15px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar-admin {
  display: flex; align-items: center; gap: 16px; padding: 16px 32px;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.topbar-admin__title h1 { font-size: 18px; }
.topbar-admin__title p { font-size: 12px; color: var(--muted); }
.topbar-admin__right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.who { font-size: 12.5px; color: var(--muted); }
.burger { display: none; background: none; border: 1px solid var(--line); border-radius: 5px; width: 36px; height: 36px; align-items: center; justify-content: center; color: var(--ink); }
.content { padding: 26px 32px 64px; max-width: 1400px; width: 100%; }

/* ---------------------------------------------------------------- buttons */
.btn-primary, .btn-ghost, .btn-danger, .btn-mini, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 5px; border: 1px solid transparent; font-size: 13px; font-weight: 600;
  padding: 9px 16px; transition: background .18s, border-color .18s, color .18s;
  cursor: pointer; white-space: nowrap;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-700); }
.btn-primary--sm { padding: 7px 13px; font-size: 12.5px; }
.btn-ghost { background: #fff; border-color: var(--line-strong); color: var(--ink-soft); }
.btn-ghost:hover { border-color: var(--green); color: var(--green); }
.btn-ghost--sm { padding: 6px 11px; font-size: 12px; }
.btn-danger { background: #fff; border-color: #e8c7c3; color: var(--danger); }
.btn-danger:hover { background: #fdf3f2; }
.btn-block { width: 100%; margin-bottom: 8px; }
.btn-mini { padding: 5px 10px; font-size: 12px; border-color: var(--line-strong); background: #fff; color: var(--ink-soft); }
.btn-mini:hover { border-color: var(--green); color: var(--green); }
.btn-mini--ghost { color: var(--muted); }
.btn-mini--danger { color: var(--danger); border-color: #e8c7c3; }
.icon-btn { background: none; border: 0; color: var(--muted); padding: 6px; }
.icon-btn:hover { color: var(--ink); }

/* ---------------------------------------------------------------- flash */
.flash { padding: 11px 16px; border-radius: 5px; font-size: 13px; margin-bottom: 18px; border: 1px solid; }
.flash--success { background: #f1f8e9; border-color: #cfe3b8; color: #2d5b0d; }
.flash--error { background: #fdf3f2; border-color: #edcfcb; color: #a52a21; }

/* ---------------------------------------------------------------- panels */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 22px; }
.panel--table { overflow: hidden; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel__head h2 { font-size: 15px; }
.panel__body { padding: 20px; }
.panel__foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; }
.panel__foot--danger { background: #fdfbfa; }
.panel__foot--inline { border-top: 1px solid var(--line); margin-top: 20px; }
.panel--sticky { position: sticky; top: 92px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.hint--sm { font-size: 12px; line-height: 1.7; }
.link { color: var(--green); font-size: 12.5px; font-weight: 600; }

/* ---------------------------------------------------------------- dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 4px; transition: border-color .2s, transform .2s; }
.stat-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.stat-card__label { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.stat-card strong { font-size: 30px; color: var(--ink); letter-spacing: -.02em; line-height: 1.2; }
.stat-card__hint { font-size: 11.5px; color: var(--muted); }
.stat-card--accent { background: var(--green); border-color: var(--green); }
.stat-card--accent .stat-card__label, .stat-card--accent .stat-card__hint { color: rgba(255, 255, 255, .7); }
.stat-card--accent strong { color: #fff; }
.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; }
.page-list { padding: 6px 20px; }
.page-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.page-list li:last-child { border-bottom: 0; }
.page-list strong { display: block; font-size: 13.5px; color: var(--ink); font-weight: 500; }
.page-list small { font-size: 11.5px; }
.quick-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; padding: 18px 20px; }
.quick-grid a { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 10px; border: 1px solid var(--line); border-radius: 5px; font-size: 12.5px; color: var(--ink-soft); transition: all .18s; }
.quick-grid a:hover { border-color: var(--green); color: var(--green); background: var(--green-50); }
.quick-grid .icon { width: 20px; height: 20px; color: var(--green); }

/* ---------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11.5px; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 11px 16px; background: #fafbf8; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid #eef1ea; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfdfa; }
.table--compact td, .table--compact th { padding: 9px 12px; }
.cell-title { font-weight: 500; color: var(--ink); display: block; }
.cell-title:hover { color: var(--green); }
.cell-sub { display: block; font-size: 11.5px; color: var(--muted); }
.row-actions { display: inline-flex; align-items: center; gap: 6px; }
.row-actions form { display: inline; }
.pill { display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 100px; font-weight: 600; white-space: nowrap; }
.pill--on { background: #eaf5dd; color: #2f5c0c; }
.pill--off { background: #f1f2ef; color: #7c8579; }
.pill--new { background: #fdf0d8; color: #8a5a06; }
.pill--processing { background: #e6f0fb; color: #1f4f86; }
.pill--done { background: #eaf5dd; color: #2f5c0c; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.list-head__actions { display: flex; align-items: center; gap: 14px; }
.search { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line-strong); border-radius: 5px; padding: 8px 12px; min-width: 280px; }
.search .icon { width: 16px; height: 16px; color: var(--muted); }
.search input { border: 0; outline: 0; font-size: 13px; width: 100%; background: transparent; }
.pager { display: flex; gap: 6px; margin-top: 18px; }
.pager a { min-width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 4px; font-size: 12.5px; background: #fff; }
.pager a.is-active { background: var(--green); border-color: var(--green); color: #fff; }

/* ---------------------------------------------------------------- forms */
.edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; padding: 22px; }
.form-grid > .col-12, .form-grid > .col-6, .form-grid > .col-4, .form-grid > .col-3, .form-grid > .col-2, .form-grid > .col-8, .form-grid > .col-1 { min-width: 0; }
.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; }
.col-2 { grid-column: span 2; }
.col-1 { grid-column: span 1; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field__label { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.field__label em { color: var(--green); font-style: normal; }
.field__help { font-size: 11.5px; color: var(--muted); }
.field input[type="text"], .field input[type="number"], .field input[type="date"], .field input[type="password"], .field select, .field textarea {
  border: 1px solid var(--line-strong); border-radius: 4px; padding: 9px 11px;
  font-family: inherit; font-size: 13.5px; color: var(--ink); background: #fff; width: 100%;
  transition: border-color .18s, box-shadow .18s;
}
.field textarea { resize: vertical; line-height: 1.7; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 0; border-color: var(--green); box-shadow: 0 0 0 3px rgba(34, 119, 0, .1); }
.form-section { font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding-top: 8px; border-top: 1px solid var(--line); margin-top: 6px; }
.form-section.is-first { border-top: 0; margin-top: 0; padding-top: 0; }
.edit-side .panel { margin-bottom: 16px; }
.meta-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; padding: 7px 0; border-bottom: 1px dashed var(--line); margin-bottom: 12px; }
.meta-row span { color: var(--muted); }
.meta-row strong { color: var(--ink); font-weight: 500; }
.page-badge { display: flex; align-items: center; gap: 10px; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track { width: 40px; height: 22px; background: #d9ded5; border-radius: 100px; position: relative; transition: background .2s; flex: none; }
.switch__dot { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.switch input:checked + .switch__track { background: var(--green); }
.switch input:checked + .switch__track .switch__dot { transform: translateX(18px); }
.switch__text { color: var(--muted); white-space: nowrap; }

/* rich text */
.rte { border: 1px solid var(--line-strong); border-radius: 4px; overflow: hidden; background: #fff; }
.rte__toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); background: #fafbf8; }
.rte__toolbar button {
  min-width: 28px; height: 26px; border: 1px solid transparent; background: none; border-radius: 3px;
  font-size: 12px; color: var(--ink-soft); padding: 0 6px;
}
.rte__toolbar button:hover { background: #fff; border-color: var(--line-strong); }
.rte__area { min-height: 180px; max-height: 520px; overflow-y: auto; padding: 14px 16px; font-size: 13.5px; line-height: 1.75; outline: 0; }
.rte__area:focus { box-shadow: inset 0 0 0 2px rgba(34, 119, 0, .12); }
.rte__area h2 { font-size: 18px; margin: 14px 0 8px; }
.rte__area h3 { font-size: 15px; margin: 12px 0 6px; }
.rte__area p { margin: 0 0 10px; }
.rte__area ul, .rte__area ol { padding-left: 20px; margin: 0 0 10px; }
.rte__area ul { list-style: disc; }
.rte__area ol { list-style: decimal; }
.rte__area a { color: var(--green); text-decoration: underline; }
.rte__area table { width: 100%; border-collapse: collapse; }
.rte__area td, .rte__area th { border: 1px solid var(--line); padding: 6px 8px; }

/* image field */
.image-field { display: grid; gap: 10px; }
.image-field__preview { width: 100%; max-width: 320px; aspect-ratio: 4 / 3; border: 1px dashed var(--line-strong); border-radius: 4px; background: #fafbf8; display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 12px; }
.image-field__preview img { width: 100%; height: 100%; object-fit: cover; }
.image-field__preview.is-empty { background: #fbfcfa; }
.image-field__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.image-field__actions input[type="text"] { max-width: 300px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.upload-inline { position: relative; overflow: hidden; }

/* rows editor */
.rows-field { border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: #fff; }
.rows-field__head, .rows-field__row { display: grid; gap: 8px; padding: 8px 10px; align-items: center; }
.rows-field__head { background: #fafbf8; border-bottom: 1px solid var(--line); font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.rows-field__row { border-bottom: 1px solid #f0f2ec; }
.rows-field__row:last-child { border-bottom: 0; }
.rows-field__row input, .rows-field__row select { border: 1px solid var(--line-strong); border-radius: 3px; padding: 6px 8px; font-size: 12.5px; width: 100%; font-family: inherit; }
.rows-field > .btn-ghost { margin: 10px; }
.rows-field__head span:last-child, .rows-field__row > button { width: 26px; }

/* tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 100px; font-size: 12.5px; background: #fff; }
.tabs a span { font-size: 11px; color: var(--muted); }
.tabs a.is-active { background: var(--green); border-color: var(--green); color: #fff; }
.tabs a.is-active span { color: rgba(255,255,255,.7); }

/* detail */
.detail-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 24px; margin: 0 0 22px; }
.detail-list div { border-bottom: 1px dashed var(--line); padding-bottom: 8px; }
.detail-list dt { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.detail-list dd { margin: 0; font-size: 13.5px; color: var(--ink); }
.message-box { background: #fafbf8; border: 1px solid var(--line); border-radius: 5px; padding: 18px; }
.message-box h3 { font-size: 12px; color: var(--muted); letter-spacing: .05em; margin-bottom: 10px; text-transform: uppercase; }
.message-box p { font-size: 14px; line-height: 1.8; }
.radio-list { display: grid; gap: 8px; margin-bottom: 16px; }
.radio-list label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.back-link { display: inline-block; font-size: 12.5px; color: var(--muted); margin-bottom: 16px; }
.back-link:hover { color: var(--green); }

/* media */
.media-uploader { display: flex; align-items: center; justify-content: space-between; gap: 20px; background: #fff; border: 1px dashed var(--line-strong); border-radius: 6px; padding: 20px 22px; margin-bottom: 20px; flex-wrap: wrap; }
.media-uploader__text { display: flex; align-items: center; gap: 14px; }
.media-uploader__text .icon { width: 26px; height: 26px; color: var(--green); }
.media-uploader__text strong { font-size: 14px; color: var(--ink); }
.media-uploader__text p { font-size: 12px; color: var(--muted); }
.upload-status { font-size: 12.5px; color: var(--green); margin-bottom: 14px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.media-item { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.media-item__thumb { aspect-ratio: 4 / 3; background: #f2f4ef; overflow: hidden; }
.media-item__thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-item figcaption { padding: 10px 12px; display: grid; gap: 3px; }
.media-item__name { font-size: 11.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item small { font-size: 10.5px; }
.media-item__actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

/* media modal */
.media-modal { position: fixed; inset: 0; background: rgba(10, 22, 14, .55); z-index: 200; display: grid; place-items: center; padding: 24px; }
.media-modal[hidden] { display: none; }
.media-modal__panel { background: #fff; border-radius: 8px; width: min(900px, 100%); max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; }
.media-modal__panel header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.media-modal__panel h2 { font-size: 15px; }
.media-modal__upload { padding: 14px 20px; border-bottom: 1px solid var(--line); }
.upload-drop { display: block; border: 1px dashed var(--line-strong); border-radius: 5px; padding: 12px; text-align: center; font-size: 12px; color: var(--muted); cursor: pointer; }
.upload-drop:hover { border-color: var(--green); color: var(--green); }
.media-modal__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; padding: 16px 20px; overflow-y: auto; }
.media-modal__grid button { border: 1px solid var(--line); background: #fff; padding: 0; border-radius: 4px; overflow: hidden; aspect-ratio: 1; }
.media-modal__grid img { width: 100%; height: 100%; object-fit: cover; }
.media-modal__grid button:hover { border-color: var(--green); box-shadow: 0 0 0 2px rgba(34,119,0,.15); }

/* ---------------------------------------------------------------- login */
.admin--login { background: #0d2b06; }
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; }
.login__card { background: #fff; border-radius: 10px; padding: 36px; width: min(420px, 100%); box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .5); }
.login__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login__brand strong { display: block; font-size: 15px; color: var(--ink); }
.login__brand small { display: block; font-size: 11px; color: var(--muted); }
.login h1 { font-size: 22px; margin-bottom: 6px; }
.login__sub { font-size: 13px; color: var(--muted); margin-bottom: 22px; }
.login__form { display: grid; gap: 14px; }
.login__form .btn-primary { width: 100%; padding: 11px; }
.login__back { display: inline-block; margin-top: 20px; font-size: 12.5px; color: var(--muted); }
.login__foot { margin-top: 22px; font-size: 11.5px; color: rgba(255, 255, 255, .4); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: repeat(3, 1fr); }
  .edit-grid { grid-template-columns: 1fr; }
  .panel--sticky { position: static; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 120; transform: translateX(-100%); transition: transform .3s ease; }
  .sidebar.is-open { transform: none; }
  .burger { display: inline-flex; }
  .content { padding: 18px 16px 48px; }
  .topbar-admin { padding: 12px 16px; }
  .form-grid { grid-template-columns: repeat(6, 1fr); padding: 16px; }
  .col-12, .col-8 { grid-column: span 6; }
  .col-6, .col-4 { grid-column: span 6; }
  .col-3, .col-2, .col-1 { grid-column: span 3; }
  .detail-list { grid-template-columns: 1fr; }
  .table { font-size: 12.5px; }
  .table th, .table td { padding: 9px 10px; }
}
