/* Admin console styles */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e2e7f0;
  --ink: #111a2e;
  --muted: #6b7590;
  --accent: #2f7cff;
  --accent-dark: #1a5ad8;
  --navy: #0c1631;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 12px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Arial, "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

/* the hidden attribute must win over the display rules further down */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.55; }
h1, h2, h3 { margin: 0 0 .3em; line-height: 1.25; }
h2 { font-size: 1.3rem; }
p { margin: 0 0 .6rem; }
.muted { color: var(--muted); font-size: .9rem; margin: 0; }
:focus-visible { outline: 3px solid rgba(47,124,255,.4); outline-offset: 2px; border-radius: 6px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid transparent; border-radius: 9px; padding: .55rem 1rem;
  font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: #b9c6e2; }
.btn.danger { background: #fff; border-color: #f3c2c2; color: var(--red); }
.btn.danger:hover { background: #fff1f1; }
.btn.tiny { padding: .35rem .7rem; font-size: .82rem; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.upload-btn { position: relative; overflow: hidden; }

/* login */
.login-screen { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #0c1631, #060b18); padding: 1.5rem; }
.login-box { width: min(100%, 380px); background: #fff; border-radius: 16px; padding: 2rem; box-shadow: 0 30px 70px rgba(0,0,0,.35); }
.login-box h1 { font-size: 1.35rem; }
.login-box label, .card label { display: block; font-size: .88rem; font-weight: 600; color: var(--muted); margin: 1.1rem 0 .3rem; }
.login-box input, .card input { width: 100%; }
.login-box .btn { width: 100%; margin-top: 1.2rem; }
.msg { min-height: 1.2em; font-size: .88rem; margin: .7rem 0 0; }
.msg.err { color: var(--red); font-weight: 600; }
.msg.ok { color: var(--green); font-weight: 600; }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .8rem 1.4rem; background: var(--navy); color: #fff;
}
.topbar-left { display: flex; align-items: center; gap: .7rem; }
.topbar-right { display: flex; align-items: center; gap: .6rem; }
.logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #37d5d6, #2f7cff); color: #04122b; font-weight: 800; font-size: .82rem; }
.save-state { font-size: .84rem; color: rgba(255,255,255,.6); }

.tabs {
  position: sticky; top: 54px; z-index: 19; display: flex; gap: .2rem; overflow-x: auto;
  background: #fff; border-bottom: 1px solid var(--line); padding: 0 1rem;
}
.tabs button {
  border: 0; background: none; font: inherit; font-size: .92rem; font-weight: 600; color: var(--muted);
  padding: .85rem .9rem; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 .35rem; border-radius: 10px; background: var(--red); color: #fff; font-size: .72rem; }

.content { padding: 1.6rem clamp(1rem, 3vw, 2rem) 4rem; max-width: 1080px; margin-inline: auto; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.3rem; }

/* cards & fields */
.card, .group, .row-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; margin-bottom: 1rem; }
.card.narrow { max-width: 430px; }
.group > h3 { font-size: 1.02rem; margin-bottom: .1rem; }
.group > .muted { margin-bottom: 1rem; }

.field { margin-bottom: 1.1rem; }
.field > label, .field-label { display: block; font-size: .86rem; font-weight: 650; color: var(--ink); margin-bottom: .35rem; }
.field .hint { font-size: .8rem; color: var(--muted); font-weight: 400; margin-left: .35rem; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; font: inherit; font-size: .93rem; color: var(--ink); background: #fbfcfe;
  border: 1px solid var(--line); border-radius: 9px; padding: .55rem .7rem;
}
textarea { resize: vertical; min-height: 76px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,124,255,.14); }

/* language tabs inside a field */
.lang-tabs { display: flex; gap: .25rem; margin-bottom: .4rem; }
.lang-tabs button {
  border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: .18rem .6rem;
  font: inherit; font-size: .78rem; font-weight: 650; color: var(--muted); cursor: pointer;
}
.lang-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.lang-tabs button.filled::after { content: "•"; color: var(--green); margin-left: .3rem; }
.lang-tabs button.active.filled::after { color: #cfe4ff; }
.lang-pane[hidden] { display: none; }

/* repeating rows */
.row-card { padding: 0; overflow: hidden; }
.row-head {
  display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; cursor: pointer;
  background: #fafbfe; border-bottom: 1px solid transparent;
}
.row-card.open .row-head { border-bottom-color: var(--line); }
.row-title { flex: 1; font-weight: 650; font-size: .96rem; }
.row-title small { display: block; color: var(--muted); font-weight: 400; font-size: .82rem; }
.row-thumb { width: 54px; height: 34px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); background: #eef1f7; }
.row-body { padding: 1.2rem; }
.row-body[hidden] { display: none; }
.row-actions { display: flex; gap: .5rem; align-items: center; }
.chevron { color: var(--muted); font-size: .8rem; }
.hidden-flag { font-size: .74rem; font-weight: 700; color: #a86b00; background: #fff4dd; border-radius: 5px; padding: .1rem .4rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.inline { display: flex; align-items: center; gap: .5rem; }
.inline input[type=checkbox] { width: 16px; height: 16px; }
.inline input[type=number] { width: 90px; }
.row-foot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 1rem; margin-top: .4rem; }

/* image field */
.image-field { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.image-preview { width: 160px; height: 100px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); background: #eef1f7; }
.image-controls { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: .5rem; }

/* media grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .9rem; }
.media-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.media-item img { width: 100%; height: 110px; object-fit: cover; display: block; background: #eef1f7; cursor: pointer; }
.media-item .media-actions { display: flex; justify-content: space-between; gap: .3rem; padding: .45rem .55rem; }
.media-item code { font-size: .7rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* leads */
.lead { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: .8rem; }
.lead.handled { opacity: .62; }
.lead-head { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.lead-head strong { font-size: 1rem; }
.lead-meta { font-size: .82rem; color: var(--muted); }
.lead-tag { font-size: .74rem; font-weight: 650; background: #eef3ff; color: var(--accent-dark); border-radius: 6px; padding: .1rem .45rem; }
.lead-msg { margin: .6rem 0 .8rem; white-space: pre-wrap; font-size: .93rem; }
.lead-actions { display: flex; gap: .5rem; }
.empty { color: var(--muted); background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); padding: 2rem; text-align: center; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(8,14,30,.6); display: grid; place-items: center; padding: 1.5rem; }
.modal-box { width: min(100%, 760px); max-height: 84vh; overflow: auto; background: #fff; border-radius: 14px; padding: 1.4rem; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.icon-btn { border: 0; background: none; font-size: 1.1rem; cursor: pointer; color: var(--muted); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 1.6rem; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: .7rem 1.2rem; border-radius: 10px;
  font-size: .92rem; z-index: 80; box-shadow: 0 12px 30px rgba(0,0,0,.3);
}
.toast.err { background: var(--red); }

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar-right .btn { padding: .5rem .7rem; }
  .save-state { display: none; }
}
