:root {
  --ink: #172039;
  --muted: #7b849d;
  --line: #e8eaf1;
  --surface: #ffffff;
  --background: #f6f7fb;
  --purple: #7057e8;
  --purple-dark: #5941cc;
  --navy: #12172a;
  --green: #2bb98a;
  --red: #ef5f73;
  --shadow: 0 18px 55px rgba(39, 43, 77, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--background); font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.brand { display: flex; align-items: center; gap: 11px; font-weight: 760; font-size: 19px; letter-spacing: .02em; }
.brand-mark { width: 38px; height: 38px; display: inline-grid; place-items: center; color: white; font-size: 12px; font-weight: 800; letter-spacing: 0; white-space: nowrap; border-radius: 11px 11px 11px 4px; background: linear-gradient(145deg, #8b71ff, #5d47da); box-shadow: 0 8px 25px rgba(111, 83, 232, .3); }
.eyebrow { display: block; color: var(--purple); font-size: 10px; letter-spacing: .18em; font-weight: 800; margin-bottom: 9px; }
.muted { color: var(--muted); }

.login-page { min-height: 100vh; background: white; }
.login-shell { display: grid; grid-template-columns: minmax(470px, 1.03fr) minmax(480px, .97fr); min-height: 100vh; }
.login-brand { position: relative; overflow: hidden; color: white; padding: 54px 9%; background: radial-gradient(circle at 20% 78%, rgba(126, 96, 243, .32), transparent 28%), radial-gradient(circle at 86% 18%, rgba(90, 69, 205, .22), transparent 24%), #12172a; display: flex; flex-direction: column; }
.login-brand::before, .login-brand::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.07); border-radius: 50%; width: 500px; height: 500px; left: -260px; bottom: -275px; }
.login-brand::after { width: 720px; height: 720px; left: -365px; bottom: -385px; }
.login-copy { position: relative; z-index: 1; margin: auto 0; max-width: 590px; }
.login-copy .eyebrow { color: #9d89ff; }
.login-copy h1 { font-size: clamp(38px, 4vw, 60px); line-height: 1.22; margin: 17px 0 25px; letter-spacing: -.045em; }
.login-copy p { color: #aeb5ca; font-size: 17px; line-height: 1.8; max-width: 480px; }
.copyright { position: relative; z-index: 1; color: #656d82; font-size: 12px; }
.brand-orbit { position: absolute; width: 180px; height: 180px; right: 8%; bottom: 10%; border: 1px solid rgba(142,119,255,.18); border-radius: 50%; animation: spin 20s linear infinite; }
.brand-orbit::before, .brand-orbit::after { content:""; position:absolute; inset: 30px; border: 1px solid rgba(142,119,255,.12); border-radius: 50%; }
.brand-orbit::after { inset: 65px; background: #7259e8; border: 0; box-shadow: 0 0 50px rgba(114,89,232,.7); }
.brand-orbit i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: #9e8aff; left: 23px; top: 23px; box-shadow: 0 0 18px #9e8aff; }
.brand-orbit i:nth-child(2) { left: auto; right: -4px; top: 85px; }
.brand-orbit i:nth-child(3) { left: 80px; top: auto; bottom: -4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-panel { display: grid; place-items: center; padding: 50px; }
.login-card { width: min(420px, 100%); }
.login-card h2 { margin: 0; font-size: 34px; letter-spacing: -.04em; }
.login-card > p { margin: 10px 0 35px; }
.mobile-logo { display: none; margin-bottom: 50px; align-items: center; gap: 10px; font-weight: 800; }
label { display: block; color: #424a62; font-size: 13px; font-weight: 650; margin: 19px 0; }
input { width: 100%; border: 1px solid #dde0e9; border-radius: 10px; background: white; padding: 13px 14px; color: var(--ink); margin-top: 8px; outline: none; transition: border .2s, box-shadow .2s; }
input:focus { border-color: #8b74eb; box-shadow: 0 0 0 3px rgba(112,87,232,.1); }
.password-field { display: flex; position: relative; }
.password-field input { padding-right: 46px; }
.password-field button { position: absolute; right: 8px; top: 15px; border: 0; background: none; color: #9aa1b4; }
.button { border: 0; border-radius: 10px; padding: 12px 18px; font-weight: 700; transition: transform .18s, box-shadow .18s, background .18s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.primary { color: white; background: linear-gradient(135deg, #7c62ed, #6249da); box-shadow: 0 9px 24px rgba(104,77,222,.22); }
.button.primary:hover:not(:disabled) { box-shadow: 0 13px 29px rgba(104,77,222,.32); }
.button.secondary { color: var(--purple); border: 1px solid #dad2fc; background: #faf9ff; }
.button.wide { width: 100%; display: flex; justify-content: center; gap: 14px; }
.login-card .button { margin-top: 28px; padding: 14px; }
.security-note { text-align: center; color: #a0a7ba; margin-top: 26px; font-size: 11px; }
.security-note span { color: var(--green); }
.alert { border-radius: 10px; padding: 12px 15px; font-size: 13px; margin: 16px 0; }
.alert.error { background: #fff1f3; color: #bd354c; border: 1px solid #ffdbe1; }
.alert.success { background: #edfbf6; color: #178361; border: 1px solid #d4f4e8; }

.app-page { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 242px; z-index: 10; display: flex; flex-direction: column; padding: 30px 22px; color: #d9dcea; background: #151a2e; }
.sidebar .brand { color: white; margin: 0 10px 45px; }
.sidebar .brand span:last-child { max-width: 135px; font-size: 14px; line-height: 1.35; }
.sidebar nav { display: grid; gap: 7px; }
.sidebar nav a { padding: 12px 14px; border-radius: 9px; color: #8e96ae; font-size: 14px; font-weight: 600; }
.sidebar nav a span { display: inline-block; width: 28px; color: #737c98; }
.sidebar nav a:hover, .sidebar nav a.active { color: white; background: rgba(118,91,232,.15); }
.sidebar nav a.active span { color: #9881ff; }
.sidebar-bottom { margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.08); }
.signed-user { display: flex; gap: 10px; align-items: center; }
.signed-user strong, .signed-user small { display: block; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signed-user strong { color: white; font-size: 13px; }
.signed-user small { color: #747c93; font-size: 10px; margin-top: 4px; }
.avatar { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: white; background: linear-gradient(135deg, #8068ea, #6048d2); font-size: 13px; }
.avatar.small { width: 30px; height: 30px; border-radius: 8px; }
.logout { border: 0; color: #737c93; background: transparent; padding: 14px 0 0; font-size: 11px; }
.logout:hover { color: white; }
.account-actions { display: flex; align-items: center; gap: 18px; }
.account-actions form { margin: 0; }
.return-admin { color: #ac9bff; }
.impersonation-banner { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 0 0 20px; padding: 13px 16px; color: #4d3aa9; border: 1px solid #ded7ff; border-radius: 10px; background: #f3f0ff; font-size: 12px; }
.impersonation-banner form, .row-actions form { margin: 0; }
.impersonation-banner button { border: 0; color: white; border-radius: 8px; background: var(--purple); padding: 8px 12px; font-weight: 700; }
.row-actions { display: flex; align-items: center; gap: 12px; }
.text-button:disabled { color: #b7bcc8; cursor: not-allowed; }
.main-content { margin-left: 242px; min-height: 100vh; padding: 34px clamp(28px, 4vw, 66px) 70px; }
.topbar { display: flex; align-items: center; gap: 20px; margin-bottom: 30px; }
.topbar h1 { font-size: 27px; margin: 0; letter-spacing: -.035em; }
.menu-button { display: none; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 20px; }
.metrics article { display: flex; gap: 16px; align-items: center; padding: 22px; border-radius: 13px; background: white; border: 1px solid #eceef4; box-shadow: 0 9px 30px rgba(42,45,75,.035); }
.metric-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px; font-size: 19px; }
.metric-icon.violet { color: #7057e8; background: #f0edff; }
.metric-icon.blue { color: #3684df; background: #eaf4ff; }
.metric-icon.green { color: #25a97e; background: #eafaf5; }
.metrics small, .metrics strong { display: block; }
.metrics small { color: var(--muted); font-size: 11px; }
.metrics strong { font-size: 25px; margin-top: 2px; }
.card, .welcome-card, .upload-card { border: 1px solid #e9ebf1; border-radius: 14px; background: white; box-shadow: 0 10px 40px rgba(37,40,72,.04); }
.card { margin-top: 20px; overflow: hidden; }
.card-heading { min-height: 78px; padding: 20px 26px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid #eff0f4; }
.card-heading h2, .welcome-card h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; min-width: 720px; }
th { padding: 12px 26px; color: #a2a8b8; background: #fafbfc; font-size: 9px; letter-spacing: .07em; text-transform: uppercase; }
td { padding: 15px 26px; border-top: 1px solid #f0f1f4; font-size: 12px; color: #606980; }
.account-cell { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.inline-form { display: flex; align-items: center; gap: 6px; }
.inline-form input { min-width: 110px; margin: 0; padding: 8px 9px; font-size: 11px; background: #fafbfc; }
.inline-form button, .text-button { color: var(--purple); border: 0; background: transparent; font-weight: 700; font-size: 10px; }
.settlement-form input:first-child { min-width: 92px; width: 92px; }
.settlement-form input:nth-child(2) { min-width: 56px; width: 56px; text-transform: uppercase; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 15px; font-size: 10px; font-weight: 650; }
.status i { width: 6px; height: 6px; border-radius: 50%; }
.status.active, .status.completed { color: #158462; background: #eaf9f4; }
.status.active i, .status.completed i { background: var(--green); }
.status.disabled, .status.failed { color: #c24457; background: #fff0f2; }
.status.disabled i, .status.failed i { background: var(--red); }
.status.processing, .status.queued { color: #6951d3; background: #f0edff; }
.status.processing i, .status.queued i { background: var(--purple); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.empty { padding: 24px; text-align: center; color: #a5abb9; }
.dylib-content { padding: 24px 26px; }
.dylib-current { display: flex; align-items: center; gap: 14px; padding: 17px; border: 1px solid #e8e9ef; border-radius: 12px; background: #fafbfc; }
.dylib-current.configured { border-color: #ddd6fb; background: #faf9ff; }
.dylib-icon { flex: 0 0 auto; width: 46px; height: 46px; display: grid; place-items: center; color: #8a91a5; background: #eceef3; border-radius: 11px; font-size: 10px; font-weight: 850; letter-spacing: .08em; }
.dylib-current.configured .dylib-icon { color: var(--purple); background: #ebe7ff; }
.dylib-info { flex: 1; min-width: 0; }
.dylib-info small, .dylib-info strong, .dylib-info span { display: block; }
.dylib-info small { color: #a1a7b7; font-size: 9px; letter-spacing: .07em; }
.dylib-info strong { margin: 3px 0 5px; color: var(--ink); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dylib-info span { color: #9299aa; font-size: 10px; }
.dylib-upload { display: flex; align-items: stretch; gap: 12px; margin-top: 14px; }
.dylib-picker { flex: 1; position: relative; display: flex; flex-direction: column; justify-content: center; min-height: 58px; margin: 0; padding: 10px 15px 10px 50px; border: 1px dashed #cbc4ef; border-radius: 10px; background: #fcfbff; cursor: pointer; }
.dylib-picker::before { content: "⇧"; position: absolute; left: 15px; top: 13px; width: 28px; height: 28px; display: grid; place-items: center; color: var(--purple); border-radius: 8px; background: #eeeaff; font-size: 15px; }
.dylib-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dylib-picker span { color: #4b536a; font-size: 11px; }
.dylib-picker small { color: #a3a8b7; font-size: 9px; margin-top: 3px; }
.dylib-upload .button { min-width: 128px; }
.dylib-note { margin: 12px 2px 0; color: #999faf; font-size: 9px; }
.welcome-card { padding: 28px 30px; display: flex; align-items: center; justify-content: space-between; background: linear-gradient(115deg, #fff, #f8f6ff); }
.channel-chip { min-width: 155px; text-align: right; border-left: 1px solid #e5e0fa; padding-left: 28px; }
.channel-chip small, .channel-chip strong { display: block; }
.channel-chip small { color: #a59eC7; font-size: 8px; letter-spacing: .14em; }
.channel-chip strong { color: var(--purple); font-size: 19px; margin-top: 5px; }
.upload-card { margin-top: 20px; padding: 22px; }
.drop-zone { min-height: 258px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; border: 1.5px dashed #cbc4ef; border-radius: 12px; background: #fbfaff; transition: .2s; }
.drop-zone.dragover { border-color: var(--purple); background: #f5f2ff; transform: scale(.998); }
.upload-icon { width: 50px; height: 50px; display: grid; place-items: center; color: var(--purple); background: #ede9ff; border-radius: 15px; font-size: 24px; margin-bottom: 13px; }
.drop-zone h3 { margin: 0 0 7px; font-size: 16px; }
.drop-zone p { color: #858da2; margin: 0 0 5px; font-size: 12px; }
.drop-zone > span { color: #b1b6c4; font-size: 9px; }
.drop-zone .button { margin-top: 18px; }
.selected-file { margin-top: 14px; padding: 12px; border: 1px solid #e4e1f3; border-radius: 10px; align-items: center; gap: 12px; background: #fcfbff; }
.selected-file:not([hidden]) { display: flex; }
.file-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; color: var(--purple); background: #eeeaff; font-size: 9px; font-weight: 800; }
.selected-file div { flex: 1; }
.selected-file strong, .selected-file small { display: block; }
.selected-file strong { font-size: 12px; }
.selected-file small { color: var(--muted); margin-top: 3px; font-size: 9px; }
.selected-file button { border: 0; background: none; color: #a1a7b6; font-size: 20px; }
.generate-button { max-width: 300px; margin: 18px auto 0; }
.records-card { margin-top: 20px; }
.stats-filters { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)) auto; align-items: end; gap: 12px; padding: 18px 26px; border-bottom: 1px solid #eff0f4; }
.stats-filters label { margin: 0; font-size: 10px; }
.stats-filters input { margin-top: 6px; padding: 10px 11px; font-size: 11px; }
.stats-filters .button { min-height: 38px; }
.stats-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: #eff0f4; border-bottom: 1px solid #eff0f4; }
.stats-summary article { padding: 20px 26px; background: white; }
.stats-summary small, .stats-summary strong { display: block; }
.stats-summary small { color: var(--muted); font-size: 10px; }
.stats-summary strong { margin-top: 5px; font-size: 24px; }
.stats-summary .stats-period { font-size: 14px; line-height: 1.7; }
.stats-subheading { padding: 17px 26px 10px; background: white; }
.stats-subheading strong { font-size: 12px; }
.channel-stats-table table { min-width: 420px; }
.package-code { display: inline-block; max-width: 190px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; color: #6550c8; font-size: 10px; white-space: nowrap; }
.install-count { color: var(--ink); font-size: 14px; }
.settlement-count, .settlement-amount { color: #13815f; }
.settlement-amount { white-space: nowrap; }
.icon-button { width: 34px; height: 34px; border-radius: 9px; border: 1px solid #e5e7ed; background: white; color: #737d94; }
.file-cell strong, .file-cell small { display: block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-cell strong { color: var(--ink); font-size: 11px; }
.file-cell small { color: #a0a6b4; font-size: 9px; margin-top: 4px; }
.download-link { color: var(--purple); font-size: 10px; font-weight: 750; padding: 6px 9px; border-radius: 7px; background: #f1eeff; }
.mini-progress { display: flex; align-items: center; gap: 8px; }
.mini-progress div { width: 65px; height: 4px; background: #ece9f9; border-radius: 5px; overflow: hidden; }
.mini-progress div span { display:block; height:100%; background: var(--purple); }
.mini-progress small { color: var(--purple); font-size: 9px; }
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(12,16,32,.62); backdrop-filter: blur(4px); }
.modal-card { position: relative; width: min(430px, 100%); padding: 31px; border-radius: 16px; background: white; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0; font-size: 23px; }
.modal-card > p { font-size: 12px; margin: 7px 0 25px; }
.modal-close { position: absolute; right: 20px; top: 18px; border: 0; background: none; color: #8d94a6; font-size: 24px; }
.modal-card.centered { text-align: center; padding: 42px; }
.progress-visual { position: relative; display: grid; place-items: center; width: 125px; height: 125px; margin: 0 auto 24px; }
.progress-ring { position: relative; z-index: 2; width: 95px; height: 95px; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--purple) var(--progress, 0%), #eae7f6 0); }
.progress-ring::before { content:""; position: absolute; inset: 8px; border-radius: 50%; background: white; }
.progress-ring span { position: relative; z-index: 1; font-weight: 800; font-size: 18px; }
.progress-visual > i { position: absolute; width: 9px; height: 9px; background: #b7a8ff; border-radius: 50%; left: 0; top: 60px; animation: float 2s ease-in-out infinite; }
.progress-visual > i:last-child { width: 6px; height: 6px; left: auto; right: 2px; top: 25px; animation-delay: -.8s; }
@keyframes float { 50% { transform: translateY(-8px); opacity: .4; } }
.progress-track { height: 6px; border-radius: 6px; background: #eeeaf8; overflow: hidden; margin: 25px 0 10px; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #846cf0, #654cdc); transition: width .4s; }
.progress-modal small { color: #9ca2b3; }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .mobile-logo { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform .25s; box-shadow: 15px 0 40px rgba(10,14,30,.25); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 24px 20px 55px; }
  .menu-button { display: block; border: 0; background: transparent; font-size: 22px; }
  .topbar { justify-content: flex-start; }
  .metrics { grid-template-columns: 1fr; }
  .stats-filters { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .login-panel { padding: 32px 25px; }
  .welcome-card, .card-heading { align-items: flex-start; flex-direction: column; }
  .dylib-upload { flex-direction: column; }
  .dylib-upload .button { width: 100%; }
  .channel-chip { width: 100%; text-align: left; border-left: 0; border-top: 1px solid #e5e0fa; padding: 18px 0 0; }
  .card-heading .button { width: 100%; }
  .stats-filters, .stats-summary { grid-template-columns: 1fr; }
  .impersonation-banner { align-items: flex-start; flex-direction: column; }
}
