:root {
  --ink: #17201c;
  --muted: #6d756f;
  --paper: #f6f5f0;
  --card: #fffefa;
  --line: #dedfd8;
  --green: #17775b;
  --green-dark: #0f5943;
  --green-soft: #e4f1eb;
  --orange: #d88442;
  --orange-soft: #faebdc;
  --red: #b94e4e;
  --red-soft: #f8e5e2;
  --shadow: 0 14px 36px rgba(25, 43, 34, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.muted { color: var(--muted); }
.small-text { font-size: 12px; }
.eyebrow { margin: 0 0 7px; font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--green); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 70% 18%, #dcecdf, transparent 28%), linear-gradient(135deg, #f8f5ed 0%, #eef2eb 100%); }
.login-card { width: min(420px, 100%); padding: 46px; border: 1px solid rgba(23, 119, 91, .15); border-radius: 28px; background: rgba(255, 254, 250, .92); box-shadow: var(--shadow); }
.login-card h1 { margin: 12px 0 8px; font-family: Georgia, "Songti SC", serif; font-size: 40px; }
.brand-mark { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 20px; background: var(--green); color: white; font-family: Georgia, serif; font-size: 30px; box-shadow: 0 10px 24px rgba(23,119,91,.25); }
.brand-mark.small { width: 42px; height: 42px; border-radius: 13px; font-size: 20px; box-shadow: none; }

.stack-form { display: grid; gap: 18px; margin-top: 30px; }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; color: #445048; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; background: white; color: var(--ink); outline: none; transition: .18s border, .18s box-shadow; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,119,91,.1); }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.form-error { min-height: 18px; margin: 0; color: var(--red); font-size: 13px; }

.button { border: 1px solid transparent; border-radius: 11px; padding: 10px 15px; font-weight: 750; color: var(--ink); background: white; transition: .18s transform, .18s background; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: var(--green-dark); }
.button.ghost { border-color: var(--line); background: transparent; }
.button.danger { background: var(--red-soft); color: var(--red); }
.button.small { padding: 7px 10px; font-size: 12px; }
.button.wide { width: 100%; padding: 13px; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--muted); }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: #f0f1ec; font-size: 24px; color: var(--muted); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 18px 20px; background: #14271f; color: white; }
.brand { display: flex; gap: 12px; align-items: center; margin: 0 10px 36px; }
.brand strong, .brand span { display: block; }
.brand strong { font-family: Georgia, "Songti SC", serif; font-size: 20px; }
.brand span { margin-top: 3px; color: #91a79d; font-size: 11px; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 13px; border: 0; border-radius: 11px; background: transparent; color: #a9b9b2; text-align: left; font-weight: 650; }
.nav-item > span { width: 18px; text-align: center; color: #7e9a8e; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.08); color: white; }
.nav-item.active > span { color: #86d1b2; }
.badge { margin-left: auto; min-width: 20px; padding: 2px 6px; border-radius: 20px; background: var(--orange); color: white; font-size: 11px; text-align: center; }
.sidebar-foot { margin-top: auto; display: flex; gap: 8px; align-items: center; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.09); color: #93a89f; font-size: 11px; }
.sidebar-foot .text-button { margin-left: auto; color: #93a89f; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #5dd19d; box-shadow: 0 0 0 4px rgba(93,209,157,.12); }

.main-content { min-width: 0; }
.topbar { height: 116px; display: flex; justify-content: space-between; align-items: center; padding: 24px 36px; border-bottom: 1px solid var(--line); background: rgba(246,245,240,.85); backdrop-filter: blur(12px); }
.topbar h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 28px; font-weight: 650; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.page-content { padding: 30px 36px 60px; }

.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 14px; }
.stat-card { padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: var(--card); box-shadow: 0 8px 24px rgba(25,43,34,.04); }
.stat-card p { margin: 0; color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin-top: 8px; font-family: Georgia, serif; font-size: 30px; }
.stat-card.accent { border-color: #b9d8ca; background: var(--green-soft); }
.section-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 18px; margin-top: 18px; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 17px; background: var(--card); overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-body { padding: 6px 20px 16px; }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; margin-bottom: 6px; color: var(--ink); }

.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 15px; }
.toolbar input { max-width: 280px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 12px 16px; background: #f0f0eb; color: var(--muted); font-size: 11px; text-align: left; letter-spacing: .04em; white-space: nowrap; }
td { padding: 15px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
td strong { font-size: 13px; }
.cell-sub { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 20px; background: #eceeea; color: #5b655f; font-size: 11px; font-weight: 750; white-space: nowrap; }
.chip.green { background: var(--green-soft); color: var(--green-dark); }
.chip.orange { background: var(--orange-soft); color: #a55b21; }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.gray { background: #eceeea; color: #68716c; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.run-list, .alert-list { list-style: none; margin: 0; padding: 0; }
.run-list li, .alert-list li { display: flex; gap: 12px; align-items: flex-start; padding: 13px 0; border-bottom: 1px solid #ecece6; }
.run-list li:last-child, .alert-list li:last-child { border-bottom: 0; }
.list-icon { flex: 0 0 auto; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: var(--green-soft); color: var(--green); font-weight: 800; }
.list-copy { min-width: 0; flex: 1; }
.list-copy strong, .list-copy span { display: block; }
.list-copy span { margin-top: 3px; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dialog { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(12,22,17,.52); }
.dialog::backdrop { background: rgba(12,22,17,.52); }
.dialog[open] { display: flex; justify-content: flex-end; }
.dialog-panel { width: min(650px, 100%); height: 100%; overflow-y: auto; background: var(--paper); box-shadow: -18px 0 50px rgba(0,0,0,.15); }
.dialog-header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 24px 28px; border-bottom: 1px solid var(--line); background: rgba(246,245,240,.94); backdrop-filter: blur(10px); }
.dialog-header h2 { margin: 0; font-family: Georgia, "Songti SC", serif; }
.dialog-body { padding: 26px 28px 60px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.switch-row { display: flex; gap: 22px; align-items: center; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.checkbox-label input { width: auto; }
.group-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 180px; overflow-y: auto; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: white; }
.content-editor { display: grid; gap: 9px; }
.content-row { display: grid; grid-template-columns: 68px 1fr auto; gap: 8px; align-items: start; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.content-row textarea { min-height: 72px; }
.content-row img { max-width: 150px; max-height: 110px; border-radius: 8px; object-fit: cover; }
.content-kind { padding-top: 10px; color: var(--green); font-size: 11px; font-weight: 800; }
.content-actions { display: grid; gap: 4px; }
.content-actions button { width: 28px; height: 26px; padding: 0; border: 0; border-radius: 7px; background: #eef0eb; color: var(--muted); }
.add-content { display: flex; gap: 7px; margin-top: 10px; }
.hint { margin: 7px 0 0; color: var(--muted); font-size: 11px; font-weight: 500; }
.pairing-box { padding: 22px; border: 1px solid #b9d8ca; border-radius: 16px; background: var(--green-soft); }
.pairing-code { display: block; margin: 8px 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 28px; letter-spacing: .08em; color: var(--green-dark); }
.notice { padding: 12px 14px; border-left: 3px solid var(--orange); border-radius: 8px; background: var(--orange-soft); color: #7e522f; font-size: 12px; line-height: 1.55; }
.toast-region { position: fixed; z-index: 30; right: 22px; bottom: 22px; display: grid; gap: 9px; }
.toast { min-width: 240px; padding: 13px 16px; border-radius: 12px; background: #14271f; color: white; box-shadow: var(--shadow); font-size: 13px; animation: toast-in .2s ease-out; }
.toast.error { background: #7f3333; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1000px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .section-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px; }
  .brand { margin: 0 4px 12px; }
  .sidebar nav { display: flex; overflow-x: auto; }
  .nav-item { width: auto; flex: 0 0 auto; }
  .sidebar-foot { display: none; }
  .topbar { height: auto; padding: 20px; align-items: flex-start; }
  .top-actions .small-text, #refresh-button { display: none; }
  .page-content { padding: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .group-checks { grid-template-columns: 1fr; }
}
