:root {
    color-scheme: light;
    --canvas: #071713;
    --canvas-2: #10221e;
    --surface: #fbfffe;
    --surface-soft: #edf7f4;
    --surface-strong: #ffffff;
    --ink: #10201c;
    --muted: #6a7773;
    --line: #d8e5e1;
    --teal: #0f766e;
    --teal-dark: #0b5f59;
    --aqua: #22d3ee;
    --mint: #4ade80;
    --amber: #f59e0b;
    --coral: #f97362;
    --red: #c24132;
    --violet: #7c3aed;
    --shadow: 0 22px 60px rgba(7, 23, 19, 0.16);
    --soft-shadow: 0 14px 34px rgba(7, 23, 19, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    color: var(--ink);
    background:
        linear-gradient(180deg, #0a1c18 0%, #f3f8f6 44%, #eaf2ef 100%);
    overflow-x: hidden;
}

.page-backdrop {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        linear-gradient(115deg, rgba(34, 211, 238, 0.18), transparent 30%, rgba(249, 115, 98, 0.14) 62%, transparent 80%),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.055) 0 1px, transparent 1px 80px),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 80px);
    background-size: 140% 140%, 80px 80px, 80px 80px;
    animation: drift-grid 18s ease-in-out infinite alternate;
}

button,
input,
textarea {
    font: inherit;
}

button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 8px;
    padding: 0 17px;
    cursor: pointer;
    font-weight: 800;
    letter-spacing: 0;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

button span {
    display: inline-grid;
    width: 18px;
    height: 18px;
    place-items: center;
    font-weight: 900;
}

.ui-icon {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-button .ui-icon {
    width: 21px;
    height: 21px;
    flex-basis: 21px;
}

button:hover {
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    cursor: wait;
    opacity: 0.66;
    transform: none;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--ink);
    outline: 0;
    padding: 13px 14px;
    transition: border 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

textarea {
    resize: vertical;
    min-height: 136px;
    font-family: Consolas, "Courier New", monospace;
}

input:focus,
textarea:focus {
    border-color: var(--teal);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.16);
}

label {
    display: grid;
    gap: 8px;
    color: #31423d;
    font-size: 14px;
    font-weight: 800;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: min(100%, 460px);
}

.login-panel {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 8px;
    background: rgba(251, 255, 254, 0.94);
    box-shadow: var(--shadow);
    padding: 30px;
    animation: lift-in 520ms ease both;
}

.login-panel::before,
.topbar::before,
.server-card::before,
.metric-card::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.62) 45%, transparent 70%);
    transform: translateX(-110%);
}

.login-panel:hover::before,
.topbar:hover::before,
.server-card:hover::before,
.metric-card:hover::before {
    animation: sweep 1100ms ease;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    position: relative;
    display: grid;
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    place-items: center;
    border-radius: 8px;
    background:
        linear-gradient(135deg, #0f766e, #22d3ee 55%, #4ade80);
    color: #ffffff;
    font-weight: 950;
    box-shadow: 0 14px 28px rgba(15, 118, 110, 0.26);
}

.brand-mark::after {
    content: "";
    position: absolute;
    inset: 7px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 6px;
}

.login-panel h1,
.topbar h1,
.section-heading h2,
.dialog-head h2,
.confirm-dialog h2 {
    margin: 4px 0 0;
    letter-spacing: 0;
}

.login-panel h1,
.topbar h1 {
    font-size: 30px;
}

.eyebrow {
    margin: 0;
    color: var(--teal);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.login-visual {
    position: relative;
    height: 136px;
    margin: 28px 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(15, 118, 110, 0.12), rgba(34, 211, 238, 0.06)),
        repeating-linear-gradient(90deg, rgba(15, 118, 110, 0.13) 0 1px, transparent 1px 34px);
}

.wave-line {
    position: absolute;
    left: 18px;
    right: 18px;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, var(--teal), var(--aqua), transparent);
    animation: scan-line 2400ms ease-in-out infinite;
}

.line-a {
    top: 34px;
}

.line-b {
    top: 68px;
    animation-delay: 400ms;
}

.line-c {
    top: 102px;
    animation-delay: 800ms;
}

.packet {
    position: absolute;
    top: 31px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--coral);
    box-shadow: 0 0 18px rgba(249, 115, 98, 0.86);
    animation: packet-run 2600ms linear infinite;
}

.packet-b {
    top: 99px;
    background: var(--mint);
    box-shadow: 0 0 18px rgba(74, 222, 128, 0.86);
    animation-delay: 900ms;
}

.login-form {
    display: grid;
    gap: 16px;
}

.primary-button {
    background: linear-gradient(135deg, var(--teal), #14b8a6);
    color: #ffffff;
    box-shadow: 0 14px 30px rgba(15, 118, 110, 0.24);
}

.primary-button:hover {
    background: linear-gradient(135deg, var(--teal-dark), #0d9488);
    box-shadow: 0 18px 36px rgba(15, 118, 110, 0.3);
}

.ghost-button {
    border: 1px solid rgba(216, 229, 225, 0.95);
    background: rgba(255, 255, 255, 0.86);
    color: var(--ink);
    box-shadow: 0 9px 20px rgba(7, 23, 19, 0.06);
}

.ghost-button:hover {
    border-color: rgba(15, 118, 110, 0.36);
    background: #ffffff;
}

.danger-button {
    border: 1px solid rgba(194, 65, 50, 0.22);
    background: #fff0ed;
    color: var(--red);
}

.danger-button:hover {
    background: #ffe4df;
    box-shadow: 0 14px 28px rgba(194, 65, 50, 0.14);
}

.icon-button {
    width: 44px;
    min-width: 44px;
    padding: 0;
    border: 1px solid rgba(216, 229, 225, 0.95);
    background: rgba(255, 255, 255, 0.86);
    color: var(--ink);
    font-size: 19px;
    line-height: 1;
    box-shadow: 0 9px 20px rgba(7, 23, 19, 0.06);
}

.form-error {
    min-height: 20px;
    margin: 0;
    color: var(--red);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.panel-page {
    padding: 24px;
}

.topbar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(1220px, 100%);
    margin: 0 auto 22px;
    gap: 18px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    background: rgba(251, 255, 254, 0.9);
    box-shadow: var(--shadow);
    padding: 16px;
    backdrop-filter: blur(16px);
    animation: lift-in 460ms ease both;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dashboard {
    display: grid;
    width: min(1220px, 100%);
    margin: 0 auto;
    gap: 22px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.metric-card,
.server-card,
.empty-state {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(216, 229, 225, 0.9);
    border-radius: 8px;
    background: rgba(251, 255, 254, 0.94);
    box-shadow: var(--soft-shadow);
}

.metric-card {
    display: grid;
    min-height: 128px;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto 1fr;
    gap: 10px 12px;
    padding: 20px;
    animation: lift-in 520ms ease both;
}

.metric-card:nth-child(2) {
    animation-delay: 70ms;
}

.metric-card:nth-child(3) {
    animation-delay: 140ms;
}

.metric-card:nth-child(4) {
    animation-delay: 210ms;
}

.metric-icon {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 8px;
    color: #ffffff;
    font-weight: 900;
    background: var(--teal);
}

.metric-icon .ui-icon {
    width: 20px;
    height: 20px;
    flex-basis: 20px;
    stroke-width: 2.35;
}

.metric-in .metric-icon {
    background: linear-gradient(135deg, var(--teal), var(--aqua));
}

.metric-out .metric-icon {
    background: linear-gradient(135deg, var(--violet), var(--coral));
}

.metric-live .metric-icon {
    background: linear-gradient(135deg, #16a34a, var(--mint));
}

.metric-sync .metric-icon {
    background: linear-gradient(135deg, #b45309, var(--amber));
}

.metric-card span {
    align-self: center;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.metric-card strong {
    grid-column: 1 / -1;
    align-self: end;
    font-size: 32px;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.server-section {
    display: grid;
    gap: 14px;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
}

.section-heading h2 {
    color: #ffffff;
    font-size: 26px;
}

.sync-status {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    gap: 9px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    background: rgba(251, 255, 254, 0.92);
    color: #31423d;
    padding: 8px 13px;
    font-size: 13px;
    font-weight: 900;
    box-shadow: var(--soft-shadow);
}

.sync-status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mint);
    box-shadow: 0 0 14px rgba(74, 222, 128, 0.76);
}

.is-busy .sync-status::before {
    border: 2px solid rgba(15, 118, 110, 0.22);
    border-top-color: var(--teal);
    background: transparent;
    animation: spin 700ms linear infinite;
}

.server-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.server-card {
    display: grid;
    gap: 16px;
    padding: 18px;
    animation: card-in 460ms ease both;
}

.server-card:nth-child(2) {
    animation-delay: 70ms;
}

.server-card:nth-child(3) {
    animation-delay: 140ms;
}

.server-card:nth-child(4) {
    animation-delay: 210ms;
}

.server-card:nth-child(n + 5) {
    animation-delay: 280ms;
}

.server-card.online {
    border-color: rgba(74, 222, 128, 0.38);
}

.server-card.offline {
    border-color: rgba(249, 115, 98, 0.38);
}

.server-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.server-title {
    min-width: 0;
}

.server-card h3 {
    margin: 0;
    font-size: 21px;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.server-card-head p,
.server-message {
    margin: 5px 0 0;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.server-message {
    min-height: 20px;
    font-size: 14px;
}

.status-pill {
    display: inline-flex;
    min-height: 30px;
    flex: 0 0 auto;
    align-items: center;
    gap: 7px;
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 900;
    background: #eef1f0;
    color: #47524f;
}

.status-pill i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.status-pill.online {
    background: #dcfce7;
    color: #166534;
}

.status-pill.online i {
    animation: pulse-dot 1300ms ease-in-out infinite;
}

.status-pill.offline {
    background: #fee2e2;
    color: #991b1b;
}

.status-pill.pending {
    background: #fff7ed;
    color: #9a3412;
}

.traffic-stack {
    display: grid;
    gap: 14px;
}

.traffic-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    align-items: center;
    gap: 14px;
}

.traffic-row span,
.server-meta dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.traffic-row strong {
    display: block;
    margin-top: 4px;
    font-size: 22px;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.traffic-track {
    position: relative;
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e7efec;
}

.traffic-track span {
    position: absolute;
    inset: 0 auto 0 0;
    min-width: 8px;
    border-radius: 999px;
    background:
        linear-gradient(90deg, var(--teal), var(--aqua)),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.36) 0 8px, transparent 8px 16px);
    animation: traffic-flow 1300ms linear infinite;
}

.traffic-track .w-5 { width: 5%; }
.traffic-track .w-10 { width: 10%; }
.traffic-track .w-15 { width: 15%; }
.traffic-track .w-20 { width: 20%; }
.traffic-track .w-25 { width: 25%; }
.traffic-track .w-30 { width: 30%; }
.traffic-track .w-35 { width: 35%; }
.traffic-track .w-40 { width: 40%; }
.traffic-track .w-45 { width: 45%; }
.traffic-track .w-50 { width: 50%; }
.traffic-track .w-55 { width: 55%; }
.traffic-track .w-60 { width: 60%; }
.traffic-track .w-65 { width: 65%; }
.traffic-track .w-70 { width: 70%; }
.traffic-track .w-75 { width: 75%; }
.traffic-track .w-80 { width: 80%; }
.traffic-track .w-85 { width: 85%; }
.traffic-track .w-90 { width: 90%; }
.traffic-track .w-95 { width: 95%; }
.traffic-track .w-100 { width: 100%; }

.traffic-track.outbound span {
    background:
        linear-gradient(90deg, var(--violet), var(--coral)),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.32) 0 8px, transparent 8px 16px);
}

.server-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
}

.server-meta div {
    min-width: 0;
}

.server-meta dd {
    margin: 5px 0 0;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.card-actions,
.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.empty-state {
    display: grid;
    justify-items: start;
    gap: 12px;
    padding: 28px;
    animation: lift-in 520ms ease both;
}

.empty-state h3,
.empty-state p {
    margin: 0;
}

.empty-state p {
    color: var(--muted);
}

.empty-visual {
    position: relative;
    width: 168px;
    height: 86px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(34, 211, 238, 0.12), rgba(74, 222, 128, 0.08)),
        repeating-linear-gradient(90deg, rgba(15, 118, 110, 0.13) 0 1px, transparent 1px 24px);
}

.node,
.link,
.traffic-dot {
    position: absolute;
    display: block;
}

.node {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--surface-strong);
    border: 3px solid var(--teal);
    box-shadow: 0 0 18px rgba(15, 118, 110, 0.28);
}

.node-a {
    left: 24px;
    top: 20px;
}

.node-b {
    right: 28px;
    top: 18px;
    border-color: var(--coral);
}

.node-c {
    left: 76px;
    bottom: 18px;
    border-color: var(--mint);
}

.link {
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--teal), var(--aqua));
    transform-origin: left center;
}

.link-a {
    left: 38px;
    top: 31px;
    width: 82px;
    transform: rotate(-2deg);
}

.link-b {
    left: 86px;
    bottom: 30px;
    width: 56px;
    transform: rotate(-26deg);
}

.traffic-dot {
    left: 36px;
    top: 27px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.8);
    animation: packet-run 1900ms linear infinite;
}

.server-dialog,
.confirm-dialog {
    width: min(740px, calc(100vw - 28px));
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 8px;
    background: rgba(251, 255, 254, 0.98);
    box-shadow: var(--shadow);
    padding: 0;
}

.confirm-dialog {
    width: min(460px, calc(100vw - 28px));
}

.server-dialog::backdrop,
.confirm-dialog::backdrop {
    background: rgba(7, 23, 19, 0.56);
    backdrop-filter: blur(5px);
}

.server-dialog[open],
.confirm-dialog[open] {
    animation: dialog-in 220ms ease both;
}

.server-dialog form,
.confirm-dialog form {
    display: grid;
    gap: 16px;
    padding: 24px;
}

.dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.confirm-mark {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 8px;
    background: #fff0ed;
    color: var(--red);
    font-size: 24px;
    font-weight: 950;
}

.confirm-dialog p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 10;
    max-width: min(420px, calc(100vw - 40px));
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: #10201c;
    color: #ffffff;
    box-shadow: var(--shadow);
    padding: 13px 16px;
    font-weight: 850;
    animation: toast-in 220ms ease both;
}

[hidden] {
    display: none !important;
}

@media (max-width: 980px) {
    .summary-grid,
    .server-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .panel-page {
        padding: 16px;
    }

    .topbar,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar-actions {
        align-items: stretch;
        display: grid;
        grid-template-columns: 1fr 1fr 44px;
    }

    .summary-grid,
    .server-grid {
        grid-template-columns: 1fr;
    }

    .traffic-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

@media (max-width: 560px) {
    .login-panel {
        padding: 22px;
    }

    .brand-row {
        align-items: flex-start;
    }

    .form-grid,
    .server-meta {
        grid-template-columns: 1fr;
    }

    .card-actions,
    .dialog-actions,
    .topbar-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .icon-button {
        width: 100%;
    }

    .metric-card strong {
        font-size: 27px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
    }
}

@keyframes drift-grid {
    from {
        background-position: 0% 0%, 0 0, 0 0;
    }
    to {
        background-position: 100% 36%, 80px 0, 0 80px;
    }
}

@keyframes lift-in {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes dialog-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes sweep {
    0% {
        opacity: 0;
        transform: translateX(-110%);
    }
    20% {
        opacity: 0.72;
    }
    100% {
        opacity: 0;
        transform: translateX(110%);
    }
}

@keyframes pulse-dot {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(22, 101, 52, 0.46);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(22, 101, 52, 0);
    }
}

@keyframes traffic-flow {
    from {
        filter: saturate(1);
    }
    to {
        filter: saturate(1.35);
    }
}

@keyframes scan-line {
    0%,
    100% {
        opacity: 0.48;
        transform: translateX(-8px);
    }
    50% {
        opacity: 1;
        transform: translateX(8px);
    }
}

@keyframes packet-run {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(126px);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
