/* ===== fonts ===== */
@font-face { font-family: 'Alp Ekran'; src: url('/fonts/AlpEkran.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Alp Kufi'; src: url('/fonts/AlpKufi.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Alp Kesme'; src: url('/fonts/AlpKesme.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Alp RuqiTom'; src: url('/fonts/Alp_RuqiTom.ttf') format('truetype'); font-display: swap; }
.f-default { font-family: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif; }
.f-alp_ekran { font-family: 'Alp Ekran', system-ui, "Microsoft YaHei", sans-serif; }
.f-alp_kufi { font-family: 'Alp Kufi', system-ui, "Microsoft YaHei", sans-serif; }
.f-alp_kesme { font-family: 'Alp Kesme', system-ui, "Microsoft YaHei", sans-serif; }
.f-alp_ruqitom { font-family: 'Alp RuqiTom', system-ui, "Microsoft YaHei", sans-serif; }

:root {
  --bg: #0b0f1a; --bg2: #111827; --card: #1a2332; --card2: #202b3d;
  --line: #2c3a52; --txt: #e7ecf5; --sub: #8ea0bc;
  --acc: #6d8dff; --acc2: #a06dff; --hot: #ff5f7a; --ok: #38d39f; --warn: #ffb454;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 15% -10%, #182244 0%, var(--bg) 55%);
  color: var(--txt);
  font-family: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}
a { color: var(--acc); text-decoration: none; }
.hidden { display: none !important; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* header */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(11, 15, 26, .82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .container { display: flex; align-items: center; gap: 18px; height: 58px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; }
.brand .dot { width: 14px; height: 26px; border-radius: 7px; background: linear-gradient(180deg, var(--acc), var(--acc2)); display: inline-block; }
nav.main { display: flex; gap: 4px; flex: 1; }
nav.main button {
  background: transparent; border: 0; color: var(--sub); font-size: 15px;
  padding: 8px 14px; border-radius: 10px; cursor: pointer;
}
nav.main button.active, nav.main button:hover { background: var(--card2); color: var(--txt); }
.userbox { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card2); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; font-size: 13px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--card2); color: var(--txt); border: 1px solid var(--line);
  padding: 9px 16px; border-radius: 10px; cursor: pointer; font-size: 14px;
  transition: .15s;
}
.btn:hover { border-color: var(--acc); }
.btn.primary { background: linear-gradient(90deg, var(--acc), var(--acc2)); border: 0; color: #fff; font-weight: 600; }
.btn.danger { background: rgba(255, 95, 122, .12); border-color: rgba(255,95,122,.4); color: #ff8ba0; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* auth */
.auth-wrap { min-height: calc(100vh - 58px); display: flex; align-items: center; justify-content: center; padding: 30px 16px; }
.auth-card {
  width: 100%; max-width: 400px; background: rgba(26,35,50,.9);
  border: 1px solid var(--line); border-radius: 20px; padding: 30px 26px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card p.sub { color: var(--sub); margin: 0 0 22px; font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--sub); margin-bottom: 6px; }
.input {
  width: 100%; background: #0e1524; color: var(--txt); border: 1px solid var(--line);
  padding: 11px 13px; border-radius: 10px; font-size: 14px; outline: none;
}
.input:focus { border-color: var(--acc); }
.seg { display: flex; background: #0e1524; border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-bottom: 20px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--sub); padding: 9px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--acc); color: #fff; font-weight: 600; }
.hint { font-size: 12px; color: var(--sub); margin-top: 14px; text-align: center; }
.err { color: #ff8ba0; font-size: 13px; margin: 8px 0 0; min-height: 18px; }

/* page title & sections */
.page-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 16px; flex-wrap: wrap; gap: 12px; }
.page-head h2 { margin: 0; font-size: 22px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips button {
  border: 1px solid var(--line); background: var(--card); color: var(--sub);
  padding: 7px 15px; border-radius: 999px; cursor: pointer; font-size: 13px;
}
.chips button.on { background: linear-gradient(90deg, var(--acc), var(--acc2)); color: #fff; border-color: transparent; }
.searchbox { position: relative; }
.searchbox input { padding-right: 34px; width: 220px; }
.searchbox::after { content: "🔍"; position: absolute; right: 11px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .7; }

/* grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }
.tile { position: relative; border-radius: var(--r); overflow: hidden; cursor: pointer; aspect-ratio: 9/16; background: var(--card2); box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.tile img { width: 100%; height: 100%; object-fit: cover; transition: .3s; display: block; }
.tile:hover img { transform: scale(1.05); }
.tile .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 10px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); color: #fff; font-size: 12px;
  display: flex; justify-content: space-between; align-items: flex-end;
}
.tile .tag { font-size: 11px; background: rgba(255,255,255,.16); padding: 2px 7px; border-radius: 6px; }
.tile .fav { position: absolute; top: 8px; right: 8px; font-size: 18px; filter: drop-shadow(0 1px 3px rgba(0,0,0,.6)); }
.tile .fav.off { filter: grayscale(1) drop-shadow(0 1px 2px rgba(0,0,0,.5)); }

/* modal */
.mask { position: fixed; inset: 0; background: rgba(5,8,16,.72); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 18px; backdrop-filter: blur(3px); }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; max-width: 720px; width: 100%; max-height: 92vh; overflow: auto; padding: 20px; }
.modal.lg { max-width: 900px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin: 0; }
.x { background: transparent; border: 0; color: var(--sub); font-size: 22px; cursor: pointer; line-height: 1; }
.preview { position: relative; width: 100%; border-radius: 14px; overflow: hidden; aspect-ratio: 9/16; max-height: 62vh; margin-bottom: 14px; }
.preview img { width: 100%; height: 100%; object-fit: cover; }
.preview .pl-overlay {
  position: absolute; inset: 0; padding: 18px; color: #fff;
  display: flex; flex-direction: column; justify-content: space-between;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.pl-row { display: flex; justify-content: space-between; }
.pl-time { font-size: 44px; font-weight: 200; line-height: 1; }
.pl-date { font-size: 14px; opacity: .9; }
.pl-text { text-align: center; font-size: 16px; line-height: 1.5; }

/* lists / tables */
.list { display: flex; flex-direction: column; gap: 10px; }
.row-card {
  display: flex; gap: 12px; align-items: center; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px;
}
.row-card img { width: 46px; height: 64px; object-fit: cover; border-radius: 8px; }
.row-card .info { flex: 1; min-width: 0; }
.row-card .info b { display: block; font-size: 14px; }
.row-card .info span { color: var(--sub); font-size: 12px; word-break: break-all; }
.row-card .ops { display: flex; gap: 6px; flex-wrap: wrap; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--sub); font-weight: 600; white-space: nowrap; }
.badge { padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge.admin { background: rgba(109,141,255,.16); color: #9fb5ff; }
.badge.user { background: rgba(142,160,188,.15); color: var(--sub); }
.badge.on { background: rgba(56,211,159,.15); color: var(--ok); }
.badge.off { background: rgba(255,180,84,.15); color: var(--warn); }
.empty { text-align: center; color: var(--sub); padding: 44px 10px; font-size: 14px; }
.switch { position: relative; width: 40px; height: 22px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #34405a; border-radius: 999px; transition: .2s; cursor: pointer; }
.switch i::before { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::before { transform: translateX(18px); }

/* widget editor */
.mock-screen {
  width: 250px; border-radius: 22px; overflow: hidden; border: 4px solid #0a0f1c;
  box-shadow: 0 0 0 1px #334, 0 18px 40px rgba(0,0,0,.5); background: #05070c;
  padding: 6px;
}
.mock-widget {
  border-radius: 16px; background: rgba(255,255,255,.14);
  backdrop-filter: blur(4px); padding: 12px; height: 150px;
  display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.editor { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
@media (max-width: 760px) { .editor { grid-template-columns: 1fr; } }
.editor .panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.color-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.color-row input[type=color] { width: 34px; height: 34px; border: 0; background: none; cursor: pointer; }
.swatches { display: flex; gap: 6px; }
.swatches i { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; display: block; }
.swatches i.on { border-color: #fff; }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.opt {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--card2);
  cursor: pointer; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.opt.on { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 90;
  background: #101a2c; border: 1px solid var(--line); color: var(--txt);
  padding: 10px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.4);
  transition: opacity .25s, transform .25s; opacity: 0; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, -6px); }
.loading { text-align: center; padding: 40px; color: var(--sub); }
