@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #060b08;
    --panel: #0d1412;
    --panel-strong: #121c19;
    --text: #eef6f3;
    --muted: #91a49e;
    --line: #243631;
    --accent: #4fbf8f;
    --accent-2: #69b7d8;
    --ok: #4ade80;
    --danger: #f87171;
    --warn: #f4c96b;
    --shadow: 0 22px 60px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: "Noto Sans Thai", Segoe UI, Arial, sans-serif;
    color: var(--text);
    background:
        linear-gradient(rgba(79, 191, 143, .025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(105, 183, 216, .025) 1px, transparent 1px),
        radial-gradient(circle at 50% 0%, rgba(36, 95, 72, .16), transparent 38%),
        var(--bg);
    background-size: 34px 34px, 34px 34px, 100% 100%, auto;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(0, 0, 0, .18), rgba(0, 0, 0, .55));
}

button, a, input { font: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: #7dffb7; }

button {
    min-height: 42px;
    border: 1px solid rgba(79, 191, 143, .36);
    border-radius: 6px;
    padding: 10px 14px;
    background: #173528;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}
button:hover { background: #1d4635; }
button:disabled {
    cursor: not-allowed;
    opacity: .58;
}
button.is-loading {
    position: relative;
    color: transparent;
}
button.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 16px;
    height: 16px;
    margin: auto;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.34);
    border-top-color: #fff;
    animation: spin .7s linear infinite;
}
button.danger, .danger button {
    border-color: rgba(255, 77, 87, .5);
    background: #3c1519;
}
button.danger:hover, .danger button:hover { background: #561d24; }

input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    background: #08110d;
    color: var(--text);
    outline: none;
}
input:focus {
    border-color: rgba(79, 191, 143, .7);
    box-shadow: 0 0 0 3px rgba(79, 191, 143, .1);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
    position: relative;
}
.login-panel {
    width: min(430px, 100%);
    position: relative;
    overflow: hidden;
    background: rgba(10, 17, 15, .96);
    border: 1px solid rgba(105, 183, 216, .24);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 22px;
}
.login-visual {
    height: 126px;
    position: relative;
    display: grid;
    place-items: center;
    margin: -4px 0 18px;
    border: 1px solid rgba(79, 191, 143, .2);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(12, 33, 27, .88), rgba(7, 12, 15, .9)),
        repeating-linear-gradient(90deg, rgba(105, 183, 216, .05) 0 1px, transparent 1px 24px);
    transform-style: preserve-3d;
    perspective: 700px;
}
.login-map {
    position: absolute;
    inset: 0;
}
.login-map .node {
    width: 14px;
    height: 14px;
}
.login-map .n1 { left: 18%; top: 62%; }
.login-map .n2 { left: 42%; top: 26%; background: var(--accent-2); }
.login-map .n3 { left: 72%; top: 44%; }
.login-map .n4 { left: 56%; top: 76%; background: var(--warn); }
.login-map .link {
    height: 2px;
}
.login-map .l1 { left: 20%; top: 64%; width: 27%; transform: rotate(-36deg); }
.login-map .l2 { left: 44%; top: 30%; width: 31%; transform: rotate(18deg); animation-delay: .5s; }
.login-map .l3 { left: 56%; top: 78%; width: 22%; transform: rotate(-54deg); animation-delay: 1s; }
.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    background: #143424;
    border: 1px solid rgba(79, 191, 143, .42);
    color: #d5fbe6;
    border-radius: 6px;
    font-weight: 800;
}
.login-brand span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}
h1 {
    margin: 3px 0 0;
    font-size: clamp(24px, 7vw, 34px);
    line-height: 1;
    letter-spacing: 0;
}
h2 { letter-spacing: 0; }
p { color: var(--muted); }
.login-copy {
    margin: 14px 0 0;
    line-height: 1.65;
}
.form { display: grid; gap: 14px; margin-top: 20px; }
label { display: grid; gap: 6px; font-weight: 650; color: #cce5d8; }
.login-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}
.login-foot span {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid rgba(105, 183, 216, .2);
    background: rgba(105, 183, 216, .08);
    color: #cde8f1;
    font-size: 12px;
    font-weight: 700;
}
.hero-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.alert, .flash {
    background: rgba(245, 200, 91, .1);
    border: 1px solid rgba(245, 200, 91, .35);
    border-radius: 8px;
    padding: 12px;
    color: #ffe7a3;
}

.toast-region {
    position: fixed;
    z-index: 80;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: grid;
    gap: 8px;
    pointer-events: none;
}
.toast {
    justify-self: center;
    width: min(520px, 100%);
    padding: 12px 14px;
    border: 1px solid rgba(79, 191, 143, .32);
    border-radius: 8px;
    background: rgba(11, 20, 17, .96);
    color: #eafff2;
    box-shadow: 0 18px 54px rgba(0, 0, 0, .45);
    opacity: 0;
    transform: translateY(12px) scale(.98);
    transition: opacity .2s ease, transform .2s ease;
}
.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.toast.success { border-color: rgba(74, 222, 128, .45); }
.toast.warning { border-color: rgba(244, 201, 107, .58); color: #ffe9ad; }
.toast.error {
    border-color: rgba(248, 113, 113, .55);
    color: #ffd0d4;
}

.page {
    width: min(1480px, 100%);
    margin: 0 auto;
    padding: 10px;
    position: relative;
}
.network-hero {
    position: relative;
    min-height: 210px;
    overflow: hidden;
    display: grid;
    align-items: end;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(22, 58, 44, .72), rgba(8, 17, 13, .94)),
        repeating-linear-gradient(90deg, rgba(79, 191, 143, .045) 0 1px, transparent 1px 54px);
    box-shadow: var(--shadow);
}
.network-hero.compact-hero {
    min-height: 150px;
}
.network-hero.compact-hero .hero-copy h1 {
    font-size: clamp(28px, 8vw, 44px);
}
.hero-copy, .hero-nav { position: relative; z-index: 2; }
.hero-kicker {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 7px 9px;
    border: 1px solid rgba(79, 191, 143, .25);
    border-radius: 999px;
    color: #ccebd9;
    background: rgba(6, 15, 10, .62);
}
.hero-kicker img {
    width: 22px;
    height: 22px;
}
.hero-copy h1 {
    margin: 12px 0 6px;
    font-size: clamp(32px, 11vw, 60px);
}
.hero-copy p { margin: 0; font-size: 16px; }
.hero-nav {
    justify-content: flex-start;
    padding-top: 4px;
}
.hero-nav span { color: var(--muted); }

.network-orbit {
    position: absolute;
    inset: 8px;
    opacity: .82;
    transform-style: preserve-3d;
    perspective: 900px;
    animation: netTilt 8s ease-in-out infinite alternate;
}
.node {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 14px rgba(79, 191, 143, .55);
}
.node.n1 { left: 18%; top: 36%; }
.node.n2 { left: 44%; top: 18%; }
.node.n3 { left: 70%; top: 34%; }
.node.n4 { left: 58%; top: 68%; }
.node.n5 { left: 24%; top: 72%; background: var(--accent-2); }
.link {
    position: absolute;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(79, 191, 143, .55), transparent);
    transform-origin: left center;
    animation: signal 2.6s linear infinite;
}
.link.l1 { left: 20%; top: 38%; width: 28%; transform: rotate(-18deg); }
.link.l2 { left: 45%; top: 22%; width: 30%; transform: rotate(18deg); animation-delay: .4s; }
.link.l3 { left: 28%; top: 72%; width: 35%; transform: rotate(-8deg); animation-delay: .8s; }
.link.l4 { left: 60%; top: 38%; width: 20%; transform: rotate(77deg); animation-delay: 1.2s; }

.status-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 10px 0;
}
.status-strip div {
    background: rgba(13, 21, 17, .88);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}
.status-strip span { display: block; color: var(--muted); font-size: 13px; }
.status-strip strong { display: block; margin-top: 3px; font-size: 24px; }
.metric-online { color: var(--ok); }
.metric-offline { color: var(--danger); }

.toolbar {
    display: grid;
    gap: 8px;
    margin-bottom: 10px;
}
.inline-action {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    background: rgba(13, 21, 17, .88);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}
.bulk-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    background: rgba(13, 21, 17, .88);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}
.select-all, .vm-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #d7e7df;
    cursor: pointer;
}
.select-all input, .vm-check input {
    width: 18px;
    min-height: 18px;
    accent-color: var(--accent);
}
.vm-check span {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1px solid rgba(79, 191, 143, .42);
    background: rgba(255, 255, 255, .04);
    display: none;
}
.bulk-form { display: none; }

.server-grid {
    display: grid;
    gap: 10px;
}
.server-card {
    position: relative;
    overflow: hidden;
    background: rgba(13, 21, 17, .94);
    border: 1px solid var(--line);
    border-left: 3px solid var(--danger);
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.server-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .42);
}
.server-card.is-online { border-left-color: var(--ok); }
.server-card.status-changed {
    animation: statusPulse .85s ease;
}
.server-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(255,255,255,.035) 0 1px, transparent 1px 12px);
    opacity: .45;
}
.server-head, .server-body, .actions {
    position: relative;
    z-index: 1;
}
.server-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 11px;
    border-bottom: 1px solid rgba(32, 54, 43, .8);
}
.rack-label {
    display: block;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0;
}
.server-head h2 {
    margin: 3px 0 0;
    font-size: 18px;
}
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 78px;
    justify-content: center;
    padding: 6px 8px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
}
.status-badge i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-badge.online {
    color: #d9fbe5;
    background: rgba(74, 222, 128, .1);
    border: 1px solid rgba(74, 222, 128, .34);
}
.status-badge.online i {
    background: var(--ok);
    box-shadow: 0 0 9px rgba(74, 222, 128, .65);
}
.status-badge.offline {
    color: #ffc2c6;
    background: rgba(255, 77, 87, .12);
    border: 1px solid rgba(255, 77, 87, .42);
}
.status-badge.offline i {
    background: var(--danger);
    box-shadow: 0 0 12px rgba(255, 77, 87, .85);
}
.server-body { padding: 11px; }
.server-leds {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-bottom: 10px;
}
.server-leds span {
    height: 5px;
    border-radius: 999px;
    background: rgba(61, 220, 132, .24);
}
.is-online .server-leds span:nth-child(1),
.is-online .server-leds span:nth-child(3) { background: var(--ok); box-shadow: 0 0 8px rgba(74, 222, 128, .45); }
.is-offline .server-leds span:nth-child(2) { background: var(--danger); box-shadow: 0 0 10px rgba(255, 77, 87, .65); }
dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
}
dt {
    color: var(--muted);
    font-size: 11px;
}
dd {
    margin: 2px 0 0;
    overflow-wrap: anywhere;
    color: #e7fff0;
    font-weight: 700;
}
.cpu-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    color: var(--muted);
}
.cpu-row b { color: var(--text); }
.meter {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, .08);
    border-radius: 999px;
    overflow: hidden;
}
.meter span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width .35s ease;
}
.user-tags {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}
.user-tags span {
    width: 100%;
    color: var(--muted);
    font-size: 12px;
}
.user-tags b {
    padding: 5px 7px;
    border-radius: 6px;
    background: rgba(90, 215, 255, .1);
    border: 1px solid rgba(90, 215, 255, .28);
    color: #c8f4ff;
    font-size: 12px;
}
.error-text {
    display: block;
    color: #ffc2c6;
    margin-top: 10px;
}
.is-hidden { display: none !important; }
.actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 0 11px 11px;
}
.actions form { margin: 0; }
.actions button { width: 100%; }

.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(0, 0, 0, .66);
    backdrop-filter: blur(18px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
}
.confirm-modal.is-open {
    opacity: 1;
    pointer-events: auto;
}
.confirm-dialog {
    width: min(460px, 100%);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(79, 191, 143, .28);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(18, 34, 28, .98), rgba(9, 15, 13, .98)),
        repeating-linear-gradient(90deg, rgba(79, 191, 143, .04) 0 1px, transparent 1px 32px);
    box-shadow: 0 30px 90px rgba(0, 0, 0, .55);
    padding: 20px;
    transform: translateY(18px) scale(.96);
    opacity: 0;
    transition: transform .22s cubic-bezier(.2, .8, .2, 1), opacity .18s ease;
}
.confirm-modal.is-open .confirm-dialog {
    transform: translateY(0) scale(1);
    opacity: 1;
}
.confirm-modal.is-danger .confirm-dialog {
    border-color: rgba(248, 113, 113, .42);
}
.confirm-modal.is-danger .confirm-dialog::before {
    background: radial-gradient(circle at top right, rgba(248, 113, 113, .18), transparent 38%);
}
.confirm-dialog::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at top right, rgba(79, 191, 143, .16), transparent 38%);
}
.confirm-mark, .confirm-dialog h2, .confirm-dialog p, .confirm-list, .confirm-actions {
    position: relative;
    z-index: 1;
}
.confirm-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(79, 191, 143, .13);
    border: 1px solid rgba(79, 191, 143, .34);
    color: #d7f8e5;
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 14px;
}
.confirm-modal.is-danger .confirm-mark {
    background: rgba(248, 113, 113, .13);
    border-color: rgba(248, 113, 113, .44);
    color: #ffd4d8;
}
.confirm-dialog h2 {
    margin: 0;
    font-size: 22px;
}
.confirm-dialog p {
    margin: 8px 0 14px;
    color: var(--muted);
}
.confirm-list {
    max-height: 190px;
    overflow: auto;
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}
.confirm-list span {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, .045);
    border: 1px solid rgba(255, 255, 255, .08);
    color: #e9fbf1;
}
.confirm-list span em {
    color: var(--muted);
    font-style: normal;
    font-size: 12px;
}
.confirm-input-wrap {
    position: relative;
    z-index: 1;
    margin-bottom: 14px;
}
.confirm-input-wrap span {
    color: #dceee6;
    font-size: 13px;
}
.confirm-input-wrap b {
    color: var(--warn);
}
.confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.log-panel {
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(13, 21, 17, .92);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.log-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid rgba(32, 54, 43, .8);
}
.log-panel-head h2 {
    margin: 0;
    font-size: 18px;
}
.log-panel-head span {
    color: var(--muted);
}
.log-list {
    display: grid;
    gap: 8px;
    padding: 10px;
}
.log-item {
    border: 1px solid rgba(79, 191, 143, .18);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    background: rgba(255, 255, 255, .035);
    padding: 10px;
}
.log-item.danger {
    border-left-color: var(--danger);
}
.log-item > div:first-child {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.log-item strong {
    color: #eafff2;
}
.log-item span {
    color: var(--muted);
    font-size: 12px;
}
.log-item dl {
    grid-template-columns: 1fr;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes statusPulse {
    0% { box-shadow: 0 0 0 0 rgba(105, 183, 216, .24), var(--shadow); }
    50% { box-shadow: 0 0 0 7px rgba(105, 183, 216, .08), var(--shadow); }
    100% { box-shadow: 0 0 0 0 rgba(105, 183, 216, 0), var(--shadow); }
}

@keyframes netTilt {
    from { transform: rotateX(58deg) rotateZ(-8deg) translateY(2px); }
    to { transform: rotateX(62deg) rotateZ(7deg) translateY(-5px); }
}
@keyframes signal {
    0% { opacity: .18; filter: brightness(.9); }
    45% { opacity: .95; filter: brightness(1.35); }
    100% { opacity: .18; filter: brightness(.9); }
}
@keyframes pulseIcon {
    0%, 100% { transform: translateZ(0) scale(1); opacity: .88; }
    50% { transform: translateZ(24px) scale(1.08); opacity: 1; }
}

@media (min-width: 640px) {
    .page { padding: 18px; }
    .network-hero {
        min-height: 230px;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: end;
    }
    .hero-nav { justify-content: flex-end; }
    .status-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .inline-action { grid-template-columns: minmax(0, 1fr) auto; }
    .bulk-panel { grid-template-columns: auto 1fr; align-items: center; }
    .server-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1120px) {
    .page { padding: 24px; }
    .network-hero { min-height: 260px; padding: 18px; }
    .server-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

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