/* 元編輯後台。站台編輯區（.ed-site）的樣子與位置跟前台 public/site.css 一致，兩邊一起改。 */
:root {
  --bg: #eff3f8; --text: #2f3d4a; --muted: #7b8794; --line: #e1e7ed;
  --primary: #337ab7; --danger: #c0392b; --bar: #364150; --bar-hover: #3f4e5e; --bar-text: #c9d5e0;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.6 "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 24px; margin: 0; font-weight: 600; }
h3 { font-size: 16px; margin: 0; font-weight: 600; }
input { font: inherit; color: inherit; background: #fff; border: 1px solid #c2cad8; border-radius: 4px; padding: 7px 10px; width: 100%; min-width: 0; }
input[type=checkbox] { width: auto; }
input[type=color] { width: 54px; height: 38px; padding: 2px; }
input:focus { outline: none; border-color: #7f9cc0; box-shadow: 0 0 0 3px rgba(51,122,183,.15); }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; align-items: flex-end; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 1px solid #c2cad8; background: #fff; color: var(--text); padding: 7px 16px; border-radius: 4px; cursor: pointer; font: inherit; white-space: nowrap; }
.btn:hover { background: #f4f6f9; }
.btn.primary { background: var(--primary); border-color: #2e6da4; color: #fff; }
.btn.primary:hover { background: #286090; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-text { border-color: transparent; color: var(--danger); margin-right: auto; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 12px; font-size: 14px; }
.btn.xs { padding: 2px 8px; font-size: 13px; }
.btn.lg { padding: 10px 24px; font-size: 16px; }
.btn.block { display: flex; width: 100%; margin-top: 12px; padding: 10px; }
.icon-btn { border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; padding: 4px 8px; }
.badge { display: inline-block; padding: 0 8px; border-radius: 3px; background: #eaf2fa; color: var(--primary); font-size: 12.5px; font-weight: 600; }

/* 後台自己的頂欄（很薄，讓下面的站台編輯區看起來跟前台一樣） */
.topbar { background: #1f2933; color: #c9d5e0; }
.topbar-row { display: flex; align-items: center; gap: 18px; min-height: 46px; }
.logo { color: #fff; font-weight: 700; font-size: 17px; }
.logo-mark { color: #60a5fa; }
.top-link { color: #c9d5e0; }
.top-link:hover { color: #fff; }
.me { display: flex; align-items: center; gap: 10px; }
.me form { margin: 0; }
.me .btn { background: transparent; color: #c9d5e0; border-color: #4b5866; }

.page { padding-top: 28px; padding-bottom: 80px; }
.page-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.page-title p { margin: 4px 0 0; }
.site-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.site-card { position: relative; overflow: hidden; display: grid; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 20px; color: var(--text); }
.site-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.site-card-bar { position: absolute; inset: 0 0 auto 0; height: 5px; }
.site-card-top { display: flex; gap: 12px; align-items: center; }
.site-card p { margin: 2px 0 0; }
.site-card .btn { margin-top: 4px; }
.site-logo { width: 44px; height: 44px; border-radius: 6px; object-fit: contain; flex: none; }
.site-logo.ph { display: grid; place-items: center; background: #eaf2fa; color: var(--primary); font-weight: 700; font-size: 20px; }
.empty-card { background: #fff; border: 1px dashed #c2cad8; border-radius: 4px; padding: 48px; text-align: center; color: var(--muted); }

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; }
.field-label { font-weight: 600; font-size: 14px; color: #44515e; }
.hint { color: var(--muted); font-size: 12.5px; }
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.logo-box { width: 64px; height: 38px; border: 1px dashed #c2cad8; border-radius: 4px; display: grid; place-items: center; overflow: hidden; }
.logo-box img { max-width: 100%; max-height: 100%; }

/* 站台編輯：上方工具列 */
.toolbar { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.toolbar-title { font-weight: 700; font-size: 17px; }

/* ===== 站台編輯區：跟前台一樣的五層位置 ===== */
.ed-site { background: #eff3f8; padding-bottom: 60px; }
.ed-head { background: #fff; }
.ed-head-row { display: flex; align-items: center; gap: 24px; min-height: 64px; padding-top: 4px; padding-bottom: 4px; }
.ed-brand { font-weight: 700; font-size: 21px; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.ed-brand img { height: 36px; }
.ed-rows { flex: 1; min-width: 0; }
.nav-area, .nav-sub-area { display: flex; justify-content: flex-end; padding: 3px 0; line-height: 1.4; }
.ed-colorbar { height: 5px; background: var(--primary); }
.ed-bar { background: var(--bar); min-height: 46px; }

.lv-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.nav-area .lv-row, .nav-sub-area .lv-row { justify-content: flex-end; }
.lv-row.vertical { flex-direction: column; align-items: stretch; gap: 0; }
.item { display: inline-flex; align-items: center; gap: 6px; position: relative; user-select: none; touch-action: none; cursor: pointer; text-decoration: none; }
.item.dragging { opacity: .5; outline: 2px dashed var(--primary); }
.item-tools { display: inline-flex; gap: 2px; margin-left: 2px; }
.tool { padding: 0 4px; border-radius: 3px; font-size: 12px; opacity: .8; }
.tool:hover { opacity: 1; background: rgba(255,255,255,.3); }

/* 第1層：頁首右側上排 */
.nav-item { font-size: .95em; padding: 3px 12px; border-radius: 3px; color: #44515e; font-weight: 600; }
.nav-item:hover { background: #eef1f5; }
.nav-item.on { background: var(--primary); color: #fff; }
/* 第2層：頁首右側下排 */
.nav-sub-item { font-size: .9em; padding: 2px 10px; color: #6b7785; border-bottom: 2px solid transparent; }
.nav-sub-item:hover { color: var(--primary); }
.nav-sub-item.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.nav-sub-item .tool:hover { background: #eef1f5; }
/* 第3層：深色列 */
.bar-a { padding: 12px 18px; color: var(--bar-text); font-weight: 600; }
.bar-a:hover { background: var(--bar-hover); color: #fff; }
.bar-a.on { background: var(--primary); color: #fff; }
.bar-a .caret { font-size: 11px; opacity: .7; }
/* 第4層往下、第5層往右（像前台的下拉選單，但點選後固定展開方便編輯） */
.ed-drop { min-height: 8px; }
.ed-holder { display: inline-flex; align-items: flex-start; }
.ed-col { background: #fff; min-width: 220px; padding: 6px 0; box-shadow: 0 8px 24px rgba(0,0,0,.15); border-radius: 0 0 4px 4px; }
.ed-col.sub { border-radius: 4px; }
.dd-a { padding: 8px 18px; color: var(--text); justify-content: flex-start; }
.dd-a:hover { background: #f4f6f9; color: var(--primary); }
.dd-a.on { background: var(--primary); color: #fff; }
.dd-a .arrow { margin-left: auto; padding-left: 12px; opacity: .6; }

/* 新增按鈕：跟該層長得一樣，只是虛線 */
.add { font: inherit; cursor: pointer; background: transparent; border: 1px dashed #b6c0ca; color: var(--primary); border-radius: 3px; }
.add.nav-item, .add.nav-sub-item { padding: 1px 10px; margin-left: 4px; }
.add.bar-a { border-color: #5b6b7d; color: #c9d5e0; padding: 6px 14px; margin: 0 6px; }
.add.dd-a { margin: 4px 10px 2px; padding: 4px 10px; justify-content: center; }
.inline-form { display: inline-flex; gap: 4px; align-items: center; padding: 3px 4px; }
.inline-form input { width: 170px; padding: 3px 8px; font-size: 14px; }
.ed-bar .inline-form { padding: 6px; }
.lv-row.vertical .inline-form { padding: 4px 10px; flex-wrap: wrap; }
.lv-row.vertical .inline-form input { width: 100%; }
.hint-row { color: var(--muted); font-size: 13px; text-align: right; width: 100%; }
.hint-row.dark { color: #8fa1b3; text-align: left; padding: 12px 6px; }

/* 導覽下方：編號 */
.code-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 10px 16px; margin-top: 14px; }
.code-lv { background: #eef1f5; color: #44515e; border-radius: 3px; padding: 1px 8px; font-size: 13px; }
.code-name { font-size: 16px; }
.code-tag { font-family: ui-monospace, Consolas, monospace; font-weight: 700; background: var(--primary); color: #fff; border-radius: 3px; padding: 2px 10px; cursor: copy; }
.code-path { color: var(--muted); font-size: 13px; }
.code-path a { color: var(--muted); }
.code-path a:hover { color: var(--primary); }

/* 工作站 */
.station { margin-top: 14px; background: #fff; border: 1px solid var(--line); border-radius: 4px; min-height: 260px; }
.station-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); font-weight: 600; }
.station-tag { background: var(--bar); color: #fff; border-radius: 3px; padding: 1px 10px; font-size: 13px; }
.station-body { padding: 40px 18px; text-align: center; }
.station-body p { margin: 4px 0; }

/* 對話框、通知 */
.modal-back { position: fixed; inset: 0; background: rgba(30,40,50,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 6px; width: min(540px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 20px; overflow: auto; }
.modal-body p { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 200; }
.toast { background: #2f8a3f; color: #fff; padding: 10px 18px; border-radius: 4px; box-shadow: 0 6px 20px rgba(0,0,0,.2); font-weight: 600; transition: opacity .3s, transform .3s; }
.toast.err { background: var(--danger); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* 登入頁 */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: #fff; border-radius: 6px; border-top: 4px solid var(--primary); padding: 34px; width: min(400px, 100%); text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.login-logo { font-size: 34px; color: var(--primary); }
.login-card h1 { margin: 6px 0 4px; }
.login-error { background: #fbeeec; color: var(--danger); border-radius: 4px; padding: 8px 10px; }

@media (max-width: 760px) {
  .wrap { padding: 0 12px; }
  .ed-head-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .nav-area, .nav-sub-area, .nav-area .lv-row, .nav-sub-area .lv-row { justify-content: flex-start; }
  .ed-holder { display: flex; flex-direction: column; margin-left: 0 !important; }
  .page-title { flex-direction: column; align-items: flex-start; }
}
