:root { color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: system-ui, sans-serif; background: #0f1117; color: #e8eaf0; }
a { color: #a29bfe; text-decoration: none; }
h2 { font-size: 16px; margin: 0 0 14px; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex-shrink: 0; background: #12141c; border-right: 1px solid #272b38; padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; }
.brand { font-size: 20px; font-weight: 700; padding: 0 10px; color: #fff; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: #9aa3b5; font-size: 14px; white-space: nowrap; }
.sidebar a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.sidebar a:hover { background: #1b1f2a; color: #e8eaf0; }
.sidebar a.active { background: #2a2550; color: #fff; }
.content { flex: 1; min-width: 0; max-width: 1100px; margin: 0 auto; padding: 32px 28px 60px; }
.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0 0 6px; font-size: 26px; }
.sub { color: #9aa3b5; margin: 0; }

@media (max-width: 800px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; gap: 10px; padding: 10px; overflow-x: auto; border-right: 0; border-bottom: 1px solid #272b38; }
  .sidebar nav { flex-direction: row; }
  .content { padding: 20px 14px 40px; }
}

/* Components */
.card { background: #181b24; border: 1px solid #272b38; border-radius: 12px; padding: 18px; }
.block { margin-top: 20px; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 160px; }
.muted { color: #9aa3b5; font-size: 12px; }
.hint { font-size: 12px; color: #9aa3b5; margin-top: 8px; }
.err { color: #ff7675; font-size: 13px; min-height: 18px; margin-top: 10px; }
.empty { text-align: center; color: #9aa3b5; padding: 30px; }

label { display: block; font-size: 13px; color: #9aa3b5; margin: 12px 0 5px; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea { width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid #323849; background: #0f1117; color: inherit; font: inherit; }
input[type=file] { width: 100%; color: #9aa3b5; }
.checks label { display: flex; gap: 8px; align-items: center; margin: 4px 0; font-size: 14px; color: #e8eaf0; cursor: pointer; }
.checks small { color: #9aa3b5; }

button { font: inherit; }
button.primary { background: #6c5ce7; color: #fff; border: 0; border-radius: 8px; padding: 9px 14px; cursor: pointer; }
button.ghost { background: none; border: 1px solid #323849; color: #e8eaf0; border-radius: 8px; padding: 9px 14px; cursor: pointer; }
button.del { background: none; border: 1px solid #55262b; color: #ff7675; border-radius: 6px; padding: 4px 10px; cursor: pointer; }
button.sm { padding: 3px 10px; font-size: 12px; border-radius: 6px; }
button:disabled { opacity: .5; cursor: wait; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.actions.left { justify-content: flex-start; }

.badge { padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #323849; }
.badge.done { background: #1e4d3a; color: #55efc4; }
.badge.error { background: #55262b; color: #ff7675; }
.badge.active { background: #4a4220; color: #ffeaa7; }
.plat { display: inline-block; margin: 0 4px 4px 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat .v { font-size: 28px; font-weight: 700; }
.stat .l { font-size: 13px; color: #9aa3b5; margin-top: 4px; }
.chart { display: flex; align-items: flex-end; gap: 10px; height: 140px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 12px; color: #9aa3b5; }
.chart .bar { width: 100%; max-width: 48px; background: #6c5ce7; border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .n { margin-bottom: 4px; color: #e8eaf0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #272b38; vertical-align: top; }
th { color: #9aa3b5; font-weight: 500; font-size: 12px; text-transform: uppercase; }
.clips a { margin-right: 8px; }
.src { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

dialog { background: #181b24; color: #e8eaf0; border: 1px solid #323849; border-radius: 12px; padding: 22px; width: min(520px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin-top: 0; }

/* Sidebar account block and admin extras */
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #5f6880; padding: 14px 12px 4px; }
.count { margin-left: auto; background: #e17055; color: #fff; font-style: normal; font-size: 11px; padding: 1px 7px; border-radius: 999px; }
.me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid #272b38; }
.me .who-name { font-size: 14px; font-weight: 600; word-break: break-all; }
.me form { margin-top: 10px; }
@media (max-width: 800px) { .me { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; align-items: center; gap: 10px; } .me form { margin: 0; } .nav-sep { display: none; } }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(440px, 100%); background: #181b24; border: 1px solid #272b38; border-radius: 14px; padding: 28px; }
.auth-card h1 { font-size: 22px; margin: 6px 0 4px; }
.brand.center { text-align: center; padding: 0; margin-bottom: 8px; }
.auth-card .sub { margin-bottom: 8px; }
.auth-card button.primary { width: 100%; padding: 12px; margin-top: 18px; font-size: 15px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 14px; color: #9aa3b5; }
.notice { background: #2a2550; border: 1px solid #4b3fb8; border-radius: 12px; padding: 16px 18px; margin: 16px 0; }
.notice p { margin: 8px 0; font-size: 14px; }
.wa-btn { display: block; text-align: center; background: #25d366; color: #05381c; font-weight: 600; padding: 12px; border-radius: 10px; margin: 12px 0 6px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form select { width: auto; padding: 4px 8px; font-size: 12px; }

/* Clip viewer */
.clip-info { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.clip-title { font-weight: 600; font-size: 14px; }
.clip-desc { color: #c4cad8; white-space: pre-wrap; word-break: break-word; }
.clip-tags { color: #a29bfe; word-break: break-word; }
.clip-actions { display: flex; gap: 6px; flex-wrap: wrap; }
dialog.wide { width: min(980px, 96vw); max-height: 92vh; overflow-y: auto; }
dialog.wide .head h2 { margin: 0; }
.viewer { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.viewer-item { display: flex; flex-direction: column; gap: 8px; }
.viewer-item video { width: 100%; max-height: 70vh; background: #000; border-radius: 8px; }

.subpick { display: flex; gap: 14px; align-items: flex-start; }
.subpick select { flex: 1; }
.subprev { width: 84px; aspect-ratio: 9 / 16; flex: none; border-radius: 8px; display: flex; align-items: flex-end;
  justify-content: center; padding: 0 5px 26px; background: linear-gradient(160deg, #3a4a6b, #1b2233 70%); overflow: hidden; }
.subprev[hidden] { display: none; }
.subprev span { font: 800 10px/1.25 Arial, sans-serif; color: #fff; text-align: center;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; }
.subprev em { font-style: normal; color: #ff0; }
.subprev[data-style="classic"] span { font-size: 8px; font-weight: 700; }
.subprev[data-style="word"] span { font-size: 18px; }
.subprev[data-style="box"] span { background: rgba(0, 0, 0, .65); text-shadow: none; padding: 2px 4px; font-size: 9px; }
.subprev[data-style="bold"] span { color: #ff0; font-size: 14px; }

.plan-pick { display: grid; gap: 8px; }
.plan-opt { display: flex !important; gap: 10px; align-items: flex-start; margin: 0 !important; padding: 10px 12px; border: 1px solid #323849; border-radius: 8px; cursor: pointer; color: #e8eaf0 !important; }
.plan-opt:has(input:checked) { border-color: #6c5ce7; background: #1d1a38; }
.plan-opt input { margin-top: 3px; width: auto; }
.plan-opt strong { display: block; font-size: 14px; }
.plan-opt small { color: #9aa3b5; font-size: 12px; line-height: 1.4; }
.plan-note { margin: 0 0 16px; padding: 10px 14px; border: 1px solid #323849; border-radius: 8px; font-size: 13px; color: #9aa3b5; background: #181b24; }

.quota { margin-top: 8px; font-size: 12px; }
.quota .q-text strong { font-size: 15px; }
.quota .q-bar { height: 6px; background: #272b38; border-radius: 3px; margin: 5px 0 3px; overflow: hidden; }
.quota .q-bar i { display: block; height: 100%; background: #6c5ce7; border-radius: 3px; }
.quota.low .q-bar i { background: #ff7675; }
.quota.low .q-text strong { color: #ff7675; }
.quota-big { margin: 0 0 12px; padding: 12px 14px; border: 1px solid #323849; border-radius: 8px; background: #181b24; font-size: 14px; }
.quota-big .q-text strong { font-size: 22px; }
@media (max-width: 800px) { .me .quota { display: none; } }

.pay-card { background: #1d1b3a; border: 1px solid #3b3590; border-radius: 12px; padding: 14px 16px; margin: 12px 0; }
.pay-card h3 { margin: 0 0 10px; font-size: 15px; }
.pay-acc { padding: 10px 0; border-top: 1px solid #2f2b63; }
.pay-acc:first-of-type { border-top: 0; padding-top: 0; }
.pay-type { margin-left: 8px; font-size: 12px; color: #9aa3b5; }
.pay-num { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.pay-num code { font-size: 15px; letter-spacing: .5px; word-break: break-all; }
.pay-form .acc-row { display: grid; grid-template-columns: 1.2fr 1.2fr 1.4fr 1fr auto; gap: 8px; margin-bottom: 8px; }
@media (max-width: 900px) { .pay-form .acc-row { grid-template-columns: 1fr 1fr; } }
