:root {
  --latte: #c2a590; --latte-deep: #aa8a72; --tint: #f3ece6; --esp: #2a1e18; --roast: #3b2a21;
  --bg: #f7f4f1; --card: #fff; --line: #e7ded6; --muted: #7d6c62; --leaf: #2f4a3f; --red: #a33d2b;
  --sun: 0 0 1px rgba(255,255,255,.55), 0 0 12px rgba(255,253,248,.5), 0 1px 2px rgba(92,64,46,.25);
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 'Urbanist', system-ui, sans-serif; background: var(--bg); color: var(--esp); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
.logo { display: block; color: #fff; filter: drop-shadow(0 0 8px rgba(255,253,248,.5)); }
.logo svg { height: 100%; width: auto; display: block; }

.login { min-height: 100vh; display: grid; place-items: center; background: var(--latte); padding: 20px; }
.login-card { background: #fff; width: min(380px, 100%); border-radius: 14px; padding: 36px; display: grid; gap: 16px; box-shadow: 0 30px 60px -30px rgba(42,30,24,.4); }
.login-card .logo { height: 26px; color: var(--latte-deep); filter: none; }
.login-card h1 { margin: 6px 0 0; font-size: 24px; }
.err { color: var(--red); min-height: 1.2em; margin: 0; }

.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--latte); color: #fff; text-shadow: var(--sun); padding: 22px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-brand { padding: 4px 10px 10px; }
.side-brand .logo { height: 18px; }
#side-nav { display: grid; gap: 2px; }
#side-nav .grp { font-size: 12px; font-weight: 700; opacity: .85; padding: 14px 12px 4px; }
#side-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; text-decoration: none; color: #fff; font-weight: 600; }
#side-nav a i { font-size: 19px; }
#side-nav a:hover { background: rgba(255,255,255,.14); }
#side-nav a.on { background: #fff; color: var(--roast); text-shadow: none; }
#side-nav .count { margin-left: auto; background: var(--esp); color: #fff; text-shadow: none; border-radius: 999px; font-size: 11.5px; padding: 1px 8px; }
.side-out { margin-top: auto; background: none; border: 1px solid rgba(255,255,255,.6); color: #fff; border-radius: 8px; padding: 9px; cursor: pointer; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; text-shadow: var(--sun); }

.main { min-width: 0; }
.main-head { position: sticky; top: 0; z-index: 10; background: rgba(247,244,241,.92); backdrop-filter: blur(10px); display: flex; align-items: center; gap: 14px; padding: 18px 32px; border-bottom: 1px solid var(--line); }
.main-head h1 { font-size: 22px; margin: 0; }
.head-actions { margin-left: auto; display: flex; gap: 10px; }
.menu-toggle { display: none; }
.view { padding: 28px 32px 80px; max-width: 1180px; }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 9px 16px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--latte-deep); }
.btn.primary { background: var(--esp); border-color: var(--esp); color: #fff; }
.btn.primary:hover { background: var(--roast); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 6px 11px; font-size: 13.5px; }
.btn i { font-size: 17px; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 18px; }
.icon-btn.danger { color: var(--red); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; margin-bottom: 20px; }
.card h2 { font-size: 17px; margin: 0 0 18px; display: flex; align-items: center; gap: 8px; }
.card h2 i { color: var(--leaf); font-size: 20px; }
.hint { color: var(--muted); font-size: 13.5px; margin: -8px 0 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span { font-weight: 600; font-size: 13.5px; color: var(--roast); }
.field small { color: var(--muted); font-size: 12.5px; }
.field input:not([type=checkbox]), .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; }
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--latte); outline-offset: 0; border-color: var(--latte-deep); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 16px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--esp); }
.icon-field { display: flex; gap: 8px; align-items: center; }
.icon-field i { font-size: 24px; width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; flex: none; color: var(--leaf); }

.media-field { display: flex; gap: 14px; align-items: center; }
.media-prev { width: 120px; height: 84px; border-radius: 8px; background: var(--tint) center/cover no-repeat; flex: none; display: grid; place-items: center; color: var(--latte-deep); font-size: 26px; overflow: hidden; border: 1px solid var(--line); }
.media-prev video { width: 100%; height: 100%; object-fit: cover; }
.media-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.media-url { font-size: 12px; color: var(--muted); word-break: break-all; margin-top: 6px; }

.list-item { border: 1px solid var(--line); border-radius: 10px; padding: 16px 16px 2px; margin-bottom: 12px; position: relative; background: #fcfbfa; }
.list-item .rm { position: absolute; top: 10px; right: 10px; }
.list-item .grid2, .list-item .field:first-child { margin-right: 40px; }

.rich-bar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--tint); }
.rich-bar button { border: 0; background: none; width: 34px; height: 32px; border-radius: 6px; cursor: pointer; font-size: 18px; }
.rich-bar button:hover { background: #fff; }
.rich { min-height: 280px; border: 1px solid var(--line); border-radius: 0 0 8px 8px; padding: 14px 18px; background: #fff; font-size: 16px; line-height: 1.65; overflow-y: auto; max-height: 60vh; }
.rich:focus { outline: 2px solid var(--latte); }
.rich img { max-width: 100%; border-radius: 6px; }
.rich h2 { font-size: 22px; } .rich h3 { font-size: 18px; }

.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12.5px; color: var(--muted); font-weight: 700; background: #fcfbfa; }
.table tr:last-child td { border-bottom: 0; }
.table .thumb { width: 46px; height: 46px; border-radius: 8px; background: var(--tint) center/cover; display: grid; place-items: center; color: var(--latte-deep); }
.table .acts { display: flex; gap: 6px; justify-content: flex-end; }
.table .muted { color: var(--muted); font-size: 13.5px; }
.pill { display: inline-block; border-radius: 999px; font-size: 12px; font-weight: 700; padding: 2px 9px; background: var(--tint); color: var(--roast); }
.pill.off { background: #f1e3e0; color: var(--red); }
.pill.new { background: var(--esp); color: #fff; }
.cat-block { margin-bottom: 28px; }
.cat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cat-head h3 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.cat-head .acts { margin-left: auto; display: flex; gap: 6px; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.mg-item { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; display: grid; cursor: default; }
.mg-item .mg-img { aspect-ratio: 1; background: var(--tint) center/cover; display: grid; place-items: center; font-size: 26px; color: var(--latte-deep); }
.mg-item .mg-img video { width: 100%; height: 100%; object-fit: cover; }
.mg-item .mg-meta { padding: 8px 10px; font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; justify-content: space-between; }
.mg-item .mg-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker .mg-item { cursor: pointer; }
.picker .mg-item:hover { outline: 2px solid var(--latte-deep); }

.msg { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 18px 20px; margin-bottom: 12px; }
.msg.unread { border-left: 4px solid var(--esp); }
.msg-head { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-bottom: 8px; }
.msg-head strong { font-size: 16px; }
.msg-head .muted { color: var(--muted); font-size: 13.5px; }
.msg-head .acts { margin-left: auto; display: flex; gap: 6px; }
.msg p { margin: 0; white-space: pre-wrap; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty i { font-size: 40px; display: block; margin-bottom: 10px; color: var(--latte-deep); }

.qr-wrap { display: grid; grid-template-columns: 280px 1fr; gap: 28px; align-items: start; }
.qr-box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: grid; place-items: center; }
.qr-box img { width: 240px; height: 240px; image-rendering: pixelated; }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-back { position: absolute; inset: 0; background: rgba(42,30,24,.5); }
.modal-card { position: relative; background: var(--bg); border-radius: 14px; width: min(760px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 40px 80px -30px rgba(0,0,0,.5); }
.modal-card.wide { width: min(1000px, 100%); }
.modal-card header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-card header h2 { margin: 0; font-size: 19px; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-card footer { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.modal-card footer:empty { display: none; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--esp); color: #fff; padding: 12px 20px; border-radius: 10px; opacity: 0; transition: .3s; pointer-events: none; z-index: 200; font-weight: 600; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .3s; }
  .side.open { transform: none; box-shadow: 20px 0 50px rgba(0,0,0,.2); }
  .menu-toggle { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 20px; }
  .main-head { padding: 14px 16px; flex-wrap: wrap; }
  .view { padding: 20px 16px 80px; }
  .grid2, .qr-wrap { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; }
}
