:root {
  color-scheme: dark;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: #07101d;
  color: #eef7ff;
  --bg: #07101d;
  --panel: rgba(10, 25, 42, 0.82);
  --panel-strong: rgba(12, 31, 52, 0.96);
  --line: rgba(137, 184, 218, 0.15);
  --muted: #83a2b9;
  --cyan: #43d9ff;
  --blue: #4b84ff;
  --green: #4ee6a4;
  --amber: #ffc45c;
  --red: #ff7184;
  --violet: #ad87ff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--bg); }
body { min-width: 320px; min-height: 100vh; margin: 0; overflow-x: hidden; background: radial-gradient(circle at 50% -20%, #163759 0, transparent 42%), linear-gradient(155deg, #050c16 0%, #071321 50%, #06101c 100%); }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.ambient { position: fixed; width: 42rem; height: 42rem; border-radius: 50%; filter: blur(110px); pointer-events: none; opacity: .13; z-index: 0; }
.ambient-one { background: #1c75ff; top: -22rem; right: -12rem; }
.ambient-two { background: #00d7bf; bottom: -28rem; left: -18rem; }
.eyebrow { margin: 0 0 .45rem; color: var(--cyan); font: 700 .68rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .18em; }

.login-view { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.login-card { width: min(440px, 100%); padding: 2.8rem; border: 1px solid rgba(109, 202, 255, .2); border-radius: 24px; background: linear-gradient(145deg, rgba(15, 34, 56, .96), rgba(6, 18, 31, .94)); box-shadow: 0 32px 100px rgba(0, 0, 0, .55), inset 0 1px rgba(255, 255, 255, .06); backdrop-filter: blur(24px); }
.brand-orbit { width: 58px; height: 58px; margin-bottom: 2rem; border: 1px solid rgba(67, 217, 255, .35); border-radius: 50%; display: grid; place-items: center; box-shadow: 0 0 30px rgba(67, 217, 255, .15); }
.brand-orbit::before, .brand-orbit::after { content: ""; position: absolute; width: 26px; height: 26px; border: 1px solid var(--cyan); transform: rotate(45deg); }
.brand-orbit::after { width: 9px; height: 9px; background: var(--cyan); box-shadow: 0 0 18px var(--cyan); }
.login-card h1 { margin: 0; font-size: clamp(2rem, 8vw, 3rem); letter-spacing: -.055em; }
.login-copy { margin: .8rem 0 2rem; color: var(--muted); line-height: 1.7; }
label { display: grid; gap: .55rem; color: #a9bfd0; font-size: .8rem; }
.login-card label + label { margin-top: 1rem; }
input { width: 100%; padding: .85rem 1rem; color: #f6fbff; border: 1px solid var(--line); border-radius: 10px; background: rgba(2, 10, 18, .65); transition: border .2s, box-shadow .2s; }
input:focus { border-color: rgba(67, 217, 255, .6); box-shadow: 0 0 0 4px rgba(67, 217, 255, .08); }
.primary-button, .ghost-button, .icon-button, .text-button { cursor: pointer; border: 0; transition: transform .18s, background .18s, border .18s, opacity .18s; }
.primary-button { min-height: 44px; padding: .75rem 1.15rem; border-radius: 10px; background: linear-gradient(115deg, #2bbfea, #397aff); color: #03101b; font-weight: 800; box-shadow: 0 10px 30px rgba(42, 160, 255, .22); }
.primary-button:hover { transform: translateY(-1px); }
.primary-button:disabled, button:disabled { cursor: wait; opacity: .55; }
.login-card .primary-button { width: 100%; margin-top: 1.4rem; }
.form-error { min-height: 1.2rem; margin: .7rem 0 0; color: var(--red); font-size: .8rem; }
.security-line { display: flex; align-items: center; gap: .55rem; margin-top: 1.3rem; color: #68859b; font-size: .72rem; }
.security-line i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }

.app { position: relative; z-index: 1; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 10; min-height: 68px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding: 0 clamp(1rem, 3vw, 3rem); border-bottom: 1px solid var(--line); background: rgba(4, 13, 23, .82); backdrop-filter: blur(20px); }
.brand { display: flex; align-items: center; gap: .8rem; color: inherit; text-decoration: none; }
.brand-symbol { position: relative; width: 29px; height: 29px; border: 1px solid var(--cyan); transform: rotate(45deg); }
.brand-symbol::after { content: ""; position: absolute; inset: 7px; background: var(--cyan); box-shadow: 0 0 14px var(--cyan); }
.brand span:last-child { display: grid; }
.brand strong { letter-spacing: .16em; }
.brand small { color: var(--muted); font-size: .56rem; letter-spacing: .16em; }
.topbar-center { display: flex; align-items: center; gap: .9rem; color: var(--muted); font-size: .76rem; }
.live-pill { display: flex; align-items: center; gap: .45rem; color: #baf9da; }
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }
.live-pill.offline { color: #ffc0ca; }
.live-pill.offline i { background: var(--red); box-shadow: 0 0 12px var(--red); }
.topbar-actions { justify-self: end; display: flex; align-items: center; gap: .55rem; }
.ghost-button { padding: .62rem .85rem; border: 1px solid var(--line); border-radius: 8px; background: rgba(22, 45, 69, .45); }
.ghost-button:hover { border-color: rgba(67, 217, 255, .45); background: rgba(29, 63, 93, .65); }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: transparent; font-size: 1.25rem; }
.icon-button:hover { background: rgba(255, 255, 255, .06); }
.text-button { padding: .6rem; color: var(--muted); background: transparent; }
.text-button:hover { color: #fff; }

main { width: min(1720px, calc(100% - 2rem)); margin: 0 auto; padding: clamp(2rem, 4vw, 4rem) 0 4rem; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; }
.hero h1 { margin: 0; max-width: 850px; font-size: clamp(2rem, 4vw, 4.4rem); line-height: .98; letter-spacing: -.06em; }
.hero > div > p:last-child { max-width: 820px; margin: 1rem 0 0; color: var(--muted); line-height: 1.7; }
.range-control { display: flex; flex-wrap: wrap; padding: .28rem; border: 1px solid var(--line); border-radius: 10px; background: rgba(5, 16, 28, .75); }
.range-control button { padding: .5rem .65rem; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: .73rem; }
.range-control button.active { color: #04131e; background: var(--cyan); font-weight: 800; }
.notice { margin: 1rem 0; padding: .85rem 1rem; border: 1px solid rgba(255, 196, 92, .3); border-radius: 10px; color: #ffe2ad; background: rgba(89, 56, 6, .22); font-size: .82rem; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: .8rem; }
.metric-card { position: relative; min-height: 132px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; padding: 1.15rem; border: 1px solid var(--line); border-radius: 15px; background: linear-gradient(145deg, rgba(15, 34, 55, .9), rgba(7, 20, 34, .75)); }
.metric-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 2px; background: var(--accent); box-shadow: 0 0 18px var(--accent); }
.metric-card::after { content: ""; position: absolute; right: -30px; top: -40px; width: 90px; height: 90px; border-radius: 50%; background: var(--accent); filter: blur(50px); opacity: .14; }
.metric-card span { color: var(--muted); font-size: .75rem; }
.metric-card strong { margin: .35rem 0; font: 700 clamp(1.55rem, 2.2vw, 2.35rem)/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: -.06em; }
.metric-card small { color: #7895aa; font-size: .68rem; }
.pool-status.healthy { color: var(--green); }.pool-status.watch { color: var(--amber); }.pool-status.critical { color: var(--red); }
.accent-cyan { --accent: var(--cyan); }.accent-green { --accent: var(--green); }.accent-violet { --accent: var(--violet); }.accent-blue { --accent: var(--blue); }.accent-amber { --accent: var(--amber); }.accent-red { --accent: var(--red); }
.secondary-metric-grid { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); margin-top: .8rem; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: rgba(8, 19, 33, .7); }
.secondary-metric { --accent: var(--cyan); position: relative; min-height: 86px; display: flex; flex-direction: column; justify-content: center; gap: .35rem; padding: 1rem 1.15rem; border-left: 1px solid var(--line); }
.secondary-metric:first-child { border-left: 0; }
.secondary-metric::before { content: ""; position: absolute; inset: 14px auto 14px 0; width: 2px; background: var(--accent); }
.secondary-metric span { color: var(--muted); font-size: .69rem; }
.secondary-metric strong { color: var(--accent); font: 700 1.15rem ui-monospace, SFMono-Regular, Consolas, monospace; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin: 3rem 0 1rem; }
.section-heading h2, .panel h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.025em; }
.section-heading > span, .panel header > span { color: var(--muted); font-size: .75rem; }
.source-grid { display: grid; grid-template-columns: repeat(3, minmax(260px, 1fr)); gap: .85rem; }
.source-card { position: relative; overflow: hidden; padding: 1.2rem; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); box-shadow: inset 0 1px rgba(255, 255, 255, .03); }
.source-card::after { content: ""; position: absolute; top: 0; right: 0; width: 42px; height: 42px; border-top: 1px solid rgba(67, 217, 255, .3); border-right: 1px solid rgba(67, 217, 255, .3); pointer-events: none; }
.source-head { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.source-head h3 { margin: 0 0 .25rem; font-size: 1.05rem; }
.source-head p { max-width: 300px; margin: 0; overflow: hidden; color: var(--muted); font-size: .69rem; text-overflow: ellipsis; white-space: nowrap; }
.source-head-side { display: grid; justify-items: end; gap: .55rem; }
.status-badge { display: inline-flex; align-items: center; gap: .4rem; padding: .32rem .52rem; border: 1px solid rgba(78, 230, 164, .25); border-radius: 999px; color: var(--green); background: rgba(78, 230, 164, .08); font-size: .63rem; }
.status-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.source-actions { position: relative; z-index: 1; display: flex; gap: .35rem; }
.source-action { padding: .28rem .48rem; border: 1px solid var(--line); border-radius: 6px; color: #9db7ca; background: rgba(2, 10, 18, .45); cursor: pointer; font-size: .64rem; }
.source-action:hover { color: #fff; border-color: rgba(67, 217, 255, .4); }
.source-action.delete:hover { color: var(--red); border-color: rgba(255, 113, 132, .4); }
.source-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin: 1.25rem 0; }
.source-metrics span { display: block; color: var(--muted); font-size: .63rem; }
.source-metrics strong { display: block; margin-top: .25rem; font: 700 1rem ui-monospace, SFMono-Regular, Consolas, monospace; }
.capacity-bar { height: 4px; overflow: hidden; border-radius: 4px; background: rgba(255, 255, 255, .07); }
.capacity-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--blue)); box-shadow: 0 0 10px var(--cyan); }
.source-environment { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1rem; }
.source-environment span { padding: .28rem .45rem; border-radius: 5px; color: #91aec3; background: rgba(255, 255, 255, .035); font-size: .6rem; }
.empty-state { grid-column: 1 / -1; padding: 4rem 2rem; border: 1px dashed rgba(137, 184, 218, .25); border-radius: 15px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: .5rem; color: #e9f7ff; font-size: 1.1rem; }
.analytics-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, .7fr); gap: .85rem; margin-top: .85rem; }
.panel { border: 1px solid var(--line); border-radius: 15px; background: var(--panel); }
.panel header { min-height: 73px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.traffic-chart { min-height: 235px; display: grid; place-items: center; padding: 1rem; color: var(--muted); }
.traffic-chart svg { width: 100%; height: 200px; overflow: visible; }
.chart-grid line { stroke: rgba(142, 183, 212, .1); stroke-width: 1; }
.chart-area { fill: url(#area-gradient); }
.chart-line { fill: none; stroke: var(--cyan); stroke-width: 2.5; filter: drop-shadow(0 0 5px rgba(67, 217, 255, .45)); }
.billing-panel { padding-bottom: 1.2rem; }
.billing-total { padding: 1.5rem 1.2rem 1.1rem; }
.billing-total span, .billing-split span { color: var(--muted); font-size: .67rem; }
.billing-total strong { display: block; margin-top: .3rem; font: 700 2.7rem ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: -.08em; }
.billing-split { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; padding: 0 1.2rem; }
.billing-split div { padding: .8rem; border-radius: 9px; background: rgba(255, 255, 255, .035); }
.billing-split strong { display: block; margin-top: .3rem; font: 700 1rem ui-monospace, SFMono-Regular, Consolas, monospace; }
.billing-panel > p { margin: 1rem 1.2rem 0; color: var(--muted); font-size: .66rem; }
.table-panel { margin-top: .85rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .75rem; }
th { padding: .72rem 1rem; color: #7493aa; background: rgba(2, 10, 18, .28); text-align: left; font: 600 .62rem ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .07em; white-space: nowrap; }
td { padding: .82rem 1rem; border-top: 1px solid rgba(137, 184, 218, .08); color: #c8d9e5; white-space: nowrap; }
tbody tr:hover { background: rgba(67, 217, 255, .025); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.result-pill { display: inline-flex; padding: .25rem .45rem; border-radius: 5px; color: var(--green); background: rgba(78, 230, 164, .08); font-size: .63rem; }
.result-pill.error { color: var(--red); background: rgba(255, 113, 132, .08); }
.table-empty { padding: 2.2rem; color: var(--muted); text-align: center; }
.throughput-panel { margin-top: .85rem; }
.throughput-chart { display: grid; gap: 0; }
.rate-lane { --rate-color: var(--cyan); display: grid; grid-template-columns: minmax(170px, .24fr) minmax(0, 1fr); align-items: center; min-height: 128px; padding: .85rem 1.2rem; border-top: 1px solid var(--line); }
.rate-lane:first-child { border-top: 0; }
.rate-lane-copy span { display: block; color: var(--muted); font-size: .68rem; }
.rate-lane-copy strong { display: block; margin: .35rem 0; color: var(--rate-color); font: 700 1.7rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: -.05em; }
.rate-lane-copy small { color: #6e8ca2; font-size: .65rem; }
.rate-lane svg { width: 100%; height: 92px; overflow: visible; }
.rate-line { fill: none; stroke: var(--rate-color); stroke-width: 2.3; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 4px color-mix(in srgb, var(--rate-color) 45%, transparent)); }
.rate-area { fill: color-mix(in srgb, var(--rate-color) 12%, transparent); }
.rate-grid { stroke: rgba(142, 183, 212, .09); stroke-width: 1; vector-effect: non-scaling-stroke; }
footer { width: min(1720px, calc(100% - 2rem)); display: flex; justify-content: space-between; gap: 1rem; margin: 0 auto; padding: 1.5rem 0 2.5rem; border-top: 1px solid var(--line); color: #557187; font-size: .66rem; }

dialog { width: min(640px, calc(100% - 2rem)); padding: 0; border: 1px solid rgba(67, 217, 255, .22); border-radius: 18px; color: inherit; background: #0a1b2c; box-shadow: 0 30px 100px rgba(0, 0, 0, .65); }
dialog::backdrop { background: rgba(1, 7, 13, .78); backdrop-filter: blur(7px); }
#source-form { padding: 1.5rem; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; }
.dialog-head h2 { margin: 0; font-size: 1.4rem; }
.dialog-copy { margin: 1rem 0 1.4rem; color: var(--muted); font-size: .77rem; line-height: 1.7; }
.dialog-copy code { color: var(--cyan); }
#source-form > label + label { margin-top: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.dialog-actions { display: flex; justify-content: end; gap: .7rem; margin-top: 1.2rem; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .secondary-metric-grid { grid-template-columns: repeat(4, 1fr); }
  .secondary-metric { border-top: 1px solid var(--line); }
  .source-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .topbar { grid-template-columns: 1fr auto; padding: .8rem 1rem; }
  .topbar-center { display: none; }
  .topbar-actions .ghost-button { font-size: 0; }
  .topbar-actions .ghost-button::after { content: "+"; font-size: 1.1rem; }
  main { width: min(100% - 1rem, 1720px); padding-top: 2rem; }
  .hero { align-items: start; flex-direction: column; }
  .hero h1 { font-size: 2.5rem; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .secondary-metric-grid { grid-template-columns: repeat(2, 1fr); }
  .source-grid, .analytics-grid { grid-template-columns: 1fr; }
  .rate-lane { grid-template-columns: 1fr; gap: .7rem; }
  .form-row { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
}
@media (max-width: 440px) {
  .login-view { padding: 1rem; }
  .login-card { padding: 1.6rem; }
  .metric-grid { grid-template-columns: 1fr; }
  .secondary-metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 105px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
