:root {
  --bg: #f5f7fb; --panel: #fff; --text: #0f1b2d; --muted: #55627a; --border: #e3e8f0;
  --primary: #1d4ed8; --primary-soft: #e8efff; --danger: #dc2626; --danger-soft: #fee2e2;
  --success: #059669; --success-soft: #dcfce7; --warn: #d97706; --warn-soft: #fef3c7;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }
a { color: var(--primary); text-decoration: none; }
p.hint { color: var(--muted); font-size: 13px; margin: 10px 0; }
p.hint code, .hint code { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--primary); color: #fff; } .btn-primary:hover { filter: brightness(.92); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); } .btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger-soft); color: var(--danger); } .btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); } .btn-ghost:hover { background: var(--border); }
.btn-sm { padding: 5px 10px; font-size: 12px; } .btn-block { width: 100%; }

/* language switch */
.lang-bar { display: flex; gap: 4px; align-items: center; font-size: 12px; font-weight: 600; }
.lang-bar a { padding: 3px 8px; border-radius: 6px; color: var(--muted); cursor: pointer; }
.lang-bar a:hover { background: var(--bg); color: var(--text); }
.lang-bar a.active { background: var(--primary-soft); color: var(--primary); }

/* auth */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-wrap { width: 100%; max-width: 400px; }
.login-wrap .lang-bar { justify-content: flex-end; margin-bottom: 10px; }
.login-box { width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: 0 10px 30px rgba(15,27,45,.08); }
.login-logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; margin-bottom: 6px; }
.login-logo img, .side-logo img { width: 32px; height: 32px; border-radius: 8px; }
.login-box .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.login-box .btn-block { margin-top: 20px; }
.login-box .alt { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin: 14px 0 6px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; padding: 0 8px 20px; white-space: nowrap; }
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav a { padding: 10px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.side nav a:hover { background: var(--bg); color: var(--text); }
.side nav a.active { background: var(--primary-soft); color: var(--primary); }
.side-foot { margin-top: auto; padding: 8px; display: grid; gap: 10px; min-width: 0; }
#side-user { overflow-wrap: anywhere; font-size: 12px; }
.main { padding: 28px 32px; max-width: 1200px; min-width: 0; overflow-x: hidden; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 800; min-width: 0; overflow-wrap: anywhere; }
.page-head .sub { color: var(--muted); font-size: 13px; font-weight: 500; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.card .k { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.card .v { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
.card .v.txt { font-size: 15px; font-weight: 700; letter-spacing: 0; }
.card .v small { font-size: 14px; color: var(--muted); font-weight: 500; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; min-width: 0; }
.panel h2 { font-size: 16px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.panel h2 .sub { font-size: 12px; color: var(--muted); font-weight: 500; }

/* table */
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
td.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 160px; max-width: 320px; }
th { background: var(--bg); font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 14px; }

/* badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.b-active, .b-paid { background: var(--success-soft); color: var(--success); }
.b-suspended, .b-banned, .b-disabled, .b-failed { background: var(--danger-soft); color: var(--danger); }
.b-expired, .b-cancelled { background: var(--border); color: var(--muted); }
.b-pending { background: var(--warn-soft); color: var(--warn); }
.b-refunded { background: #ede9fe; color: #6d28d9; }
.b-gb { background: var(--primary-soft); color: var(--primary); }
.b-mbps { background: #ede9fe; color: #6d28d9; }

/* progress */
.prog { width: 140px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px; }
.prog i { display: block; height: 100%; background: var(--primary); }
.prog.warn i { background: var(--warn); } .prog.over i { background: var(--danger); }

/* tabs */
.tabs { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 4px; gap: 4px; margin-bottom: 20px; }
.tabs a { padding: 7px 16px; border-radius: 7px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs a.active { background: var(--primary-soft); color: var(--primary); }

/* plan cards */
.plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.plan { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.plan:hover { border-color: var(--primary); box-shadow: 0 6px 18px rgba(29,78,216,.08); }
.plan .name { font-weight: 800; font-size: 16px; }
.plan .big { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.plan .big small { font-size: 14px; color: var(--muted); font-weight: 500; }
.plan .meta { color: var(--muted); font-size: 13px; }
.plan .price { font-size: 22px; font-weight: 800; margin-top: 10px; }
.plan .btn { margin-top: 12px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(15,27,45,.45); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal-box { background: var(--panel); border-radius: 16px; padding: 28px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-box h3 { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.summary { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 10px; }
.summary div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 13px; }
.summary div b { color: var(--muted); font-weight: 600; }

/* credentials */
.cred { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; min-width: 0; }
.cred .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.cred .head .name { font-weight: 700; display: flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.cred-box { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-top: 10px; }
.cred-box .row { display: flex; align-items: flex-start; padding: 6px 0; gap: 12px; border-bottom: 1px solid var(--border); }
.cred-box .row:last-child { border-bottom: 0; }
.cred-box .row b { flex: 0 0 72px; font-weight: 600; color: var(--muted); font-size: 12px; line-height: 20px; }
.cred-box .row code { flex: 1 1 auto; min-width: 0; word-break: break-all; line-height: 20px; }
.cred-box .row .copy, .cred-box .row .eye { flex: 0 0 auto; white-space: nowrap; line-height: 20px; }
.cred-box code { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 13px; user-select: all; }
.copy { cursor: pointer; color: var(--primary); font-size: 12px; font-weight: 600; }
.eye { cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600; } .eye:hover { color: var(--text); }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100vw - 40px); text-align: center; }
.toast.error { background: var(--danger); }

/* chart */
.chart { display: flex; align-items: flex-end; gap: 2px; height: 120px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.chart i { flex: 1; background: var(--primary); border-radius: 2px 2px 0 0; min-width: 3px; opacity: .85; }
.chart i:hover { opacity: 1; }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }

/* account */
.form-narrow { max-width: 420px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: 14px; }
.kv b { color: var(--muted); font-weight: 600; }
.kv span { overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 12px; overflow-x: auto; }
  .side-logo { padding: 0 8px 0 0; }
  .side nav { flex-direction: row; }
  .side-foot { margin-top: 0; margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 0; }
  .side-foot #side-user { display: none; }
  .side-foot .btn-block { width: auto; }
  .main { padding: 18px 14px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv b { margin-top: 8px; }
  .cred-box .row { flex-wrap: wrap; }
  .cred-box .row b { flex-basis: 100%; }
}
.bw-wrap { position: relative; width: 100%; }
.bw-svg { display: block; font-family: inherit; }
.c-grid { stroke: var(--border); stroke-width: 1; }
.c-axis { fill: var(--muted); font-size: 11px; }
.c-empty { fill: var(--muted); font-size: 13px; }
.c-area { fill: var(--primary); opacity: .10; }
.c-line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; }
.c-line-in { fill: none; stroke: #0ea5e9; stroke-width: 1.2; stroke-dasharray: 3 3; opacity: .8; }
.c-limit { stroke: var(--danger); stroke-width: 1.2; stroke-dasharray: 6 4; opacity: .7; }
.c-limit-txt { fill: var(--danger); font-size: 11px; font-weight: 600; }
.c-vline { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 2; }
.c-dot { fill: var(--primary); stroke: #fff; stroke-width: 2; }
.c-bar { fill: var(--primary); opacity: .85; } .c-bar:hover { opacity: 1; }
.c-tip { position: absolute; pointer-events: none; background: var(--text); color: #fff; font-size: 12px; line-height: 1.5; padding: 6px 10px; border-radius: 8px; white-space: nowrap; box-shadow: 0 6px 18px rgba(0,0,0,.2); z-index: 5; }
.c-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.c-legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 5px; border-radius: 2px; }
.c-legend .l-tot i { background: var(--primary); } .c-legend .l-in i { background: #0ea5e9; } .c-legend .l-lim i { background: var(--danger); }
.live { display: inline-flex; align-items: center; gap: 6px; }
.live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }
