* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(25, 118, 210, 0.18), transparent 30%),
        radial-gradient(circle at right 20%, rgba(230, 126, 34, 0.14), transparent 24%),
        linear-gradient(180deg, #0b0f16 0%, #090b10 100%);
    color: #edf2f7;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ===== Animations ===== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes flashFadeOut {
    0%,80% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-6px); pointer-events: none; }
}

/* ===== Page Glow ===== */

.page-glow {
    position: fixed;
    width: 420px;
    height: 420px;
    border-radius: 999px;
    filter: blur(90px);
    opacity: 0.28;
    pointer-events: none;
    z-index: 0;
}

.page-glow-a {
    top: -120px;
    left: -100px;
    background: #1976d2;
}

.page-glow-b {
    right: -120px;
    top: 120px;
    background: #e67e22;
}

/* ===== Layout ===== */

.layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ===== Sidebar ===== */

.sidebar {
    background: rgba(11, 15, 22, 0.88);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(18px);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
}

.menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1100;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(11,15,22,0.92);
    backdrop-filter: blur(12px);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.16s;
}

.menu-toggle:hover {
    background: rgba(25,118,210,0.25);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.28s;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
    border: 1px solid rgba(255,255,255,0.06);
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-weight: 800;
    letter-spacing: 1px;
    color: #ffffff;
    font-size: 15px;
    background: linear-gradient(135deg, #1976d2, #7b61ff);
    box-shadow: 0 8px 24px rgba(25,118,210,0.35);
    flex-shrink: 0;
}

.brand-title {
    font-size: 20px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.3px;
}

.brand-subtitle {
    color: #e67e22;
    margin-top: 4px;
    font-size: 12px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 13px;
    border-radius: 12px;
    color: #b0bac8;
    background: transparent;
    border: 1px solid transparent;
    font-size: 14px;
    transition: all 0.18s ease;
}

.nav-link:hover {
    background: rgba(255,255,255,0.05);
    color: #e0e8f0;
    border-color: rgba(255,255,255,0.06);
}

.nav-link.active {
    background: linear-gradient(180deg, rgba(25,118,210,0.22), rgba(25,118,210,0.08));
    color: #ffffff;
    border-color: rgba(25,118,210,0.3);
    box-shadow: 0 6px 20px rgba(25,118,210,0.14);
    font-weight: 600;
}

.nav-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 700;
    color: #c8d8f0;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.07);
    transition: all 0.18s;
}

.nav-link.active .nav-icon,
.nav-link:hover .nav-icon {
    background: rgba(25,118,210,0.28);
    border-color: rgba(25,118,210,0.35);
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
}

.admin-name {
    font-weight: 700;
    color: #ffffff;
    font-size: 14px;
}

/* ===== Main Content ===== */

.content {
    padding: 24px 28px;
    max-width: 1600px;
    animation: fadeIn 0.3s ease;
}

/* ===== Topbar ===== */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
    padding: 18px 22px;
    border-radius: 18px;
    background: rgba(16,20,28,0.72);
    border: 1px solid rgba(255,255,255,0.06);
    backdrop-filter: blur(14px);
    box-shadow: 0 14px 40px rgba(0,0,0,0.2);
    animation: fadeSlideDown 0.35s ease;
}

.topbar h1,
.card-head h2 {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 6px;
    color: #8bb8ff;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-weight: 600;
}

.page-subtitle {
    margin-top: 6px;
    max-width: 680px;
    color: #8e99a9;
    font-size: 13px;
    line-height: 1.65;
}

.topbar-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.soft-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    font-size: 12px;
    color: #c8d4e0;
    white-space: nowrap;
}

.soft-badge-ok {
    background: rgba(46,125,50,0.16);
    border-color: rgba(46,125,50,0.3);
    color: #a8e6ab;
}

.soft-badge-warn {
    background: rgba(239,108,0,0.16);
    border-color: rgba(239,108,0,0.3);
    color: #ffc078;
}

/* ===== Cards ===== */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.grid-two {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 16px;
}

.card {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015)),
        rgba(17,21,30,0.9);
    border: 1px solid rgba(255,255,255,0.065);
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.18);
    animation: fadeSlideUp 0.35s ease both;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.stat-card {
    min-height: 110px;
    position: relative;
    overflow: hidden;
    cursor: default;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: rgba(25,118,210,0.2);
    box-shadow: 0 16px 40px rgba(0,0,0,0.24);
}

.stat-card::after {
    content: "";
    position: absolute;
    inset: auto -20px -30px auto;
    width: 100px;
    height: 100px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(25,118,210,0.2), transparent 65%);
    transition: opacity 0.3s;
}

.stat-card:hover::after {
    opacity: 0.6;
}

.stat-value {
    margin-top: 10px;
    font-size: 28px;
    font-weight: 800;
    color: #ffffff;
    word-break: break-word;
    letter-spacing: -0.02em;
}

.status-text {
    text-transform: capitalize;
}

.muted {
    color: #8b96a6;
    font-size: 13px;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

/* ===== Flash Messages ===== */

.flash-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.flash {
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    animation: fadeSlideDown 0.3s ease;
    font-size: 14px;
}

.flash-success {
    background: rgba(46,125,50,0.14);
    border-color: rgba(46,125,50,0.38);
    animation: fadeSlideDown 0.3s ease, flashFadeOut 6s ease forwards;
}

.flash-error {
    background: rgba(229,57,53,0.14);
    border-color: rgba(229,57,53,0.34);
}

.flash-close {
    background: none;
    border: none;
    color: #aaa;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.flash-close:hover {
    opacity: 1;
    color: #fff;
}

/* ===== Buttons ===== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 0;
    border-radius: 11px;
    padding: 10px 16px;
    color: #ffffff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: transform 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease;
    position: relative;
}

.btn:hover {
    opacity: 0.95;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0) scale(0.97);
    opacity: 0.9;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, #2e7d32, #43a047);
    box-shadow: 0 8px 20px rgba(46,125,50,0.22);
}

.btn-secondary {
    background: linear-gradient(135deg, #1976d2, #3f8efc);
    box-shadow: 0 8px 20px rgba(25,118,210,0.2);
}

.btn-danger {
    background: linear-gradient(135deg, #c62828, #e53935);
    box-shadow: 0 8px 20px rgba(198,40,40,0.2);
}

.btn-warning {
    background: linear-gradient(135deg, #ef6c00, #fb8c00);
    box-shadow: 0 8px 20px rgba(239,108,0,0.18);
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: none;
    color: #c8d4e0;
}

.btn-outline:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.2);
}

.btn-block {
    width: 100%;
}

.btn-small {
    padding: 7px 10px;
    font-size: 12px;
    border-radius: 9px;
}

.btn-loading .btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ===== Forms ===== */

.form-grid {
    display: grid;
    gap: 14px;
}

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

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field > span {
    font-size: 13px;
    color: #c0c8d4;
    font-weight: 500;
}

.field-full {
    grid-column: 1 / -1;
}

.field-hint {
    font-size: 12px;
    color: #6b7888;
    margin-top: -2px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(7,10,16,0.88);
    color: #ffffff;
    border-radius: 10px;
    padding: 11px 13px;
    font-size: 14px;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input::placeholder,
textarea::placeholder {
    color: rgba(255,255,255,0.2);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(63,142,252,0.65);
    box-shadow: 0 0 0 3px rgba(25,118,210,0.14);
    background: rgba(10,13,20,0.98);
}

input[type="checkbox"] {
    width: auto;
    accent-color: #3f8efc;
}

.section-label {
    margin-top: 6px;
    margin-bottom: -2px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.035);
    border: 1px solid rgba(255,255,255,0.06);
    border-left: 3px solid rgba(25,118,210,0.5);
    color: #d0daea;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

/* ===== Tables ===== */

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 11px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    text-align: left;
    vertical-align: middle;
    font-size: 13px;
    word-break: break-word;
    line-height: 1.5;
}

th {
    color: #a8b4c4;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(255,255,255,0.025);
    position: sticky;
    top: 0;
    z-index: 2;
}

.table-wrap {
    overflow-x: auto;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.05);
    background: rgba(6,9,14,0.5);
}

tbody tr {
    transition: background 0.14s ease, border-color 0.14s ease;
    border-left: 3px solid transparent;
}

tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.012);
}

tbody tr:hover {
    background: rgba(25,118,210,0.06);
    border-left-color: rgba(25,118,210,0.5);
}

.empty-row {
    text-align: center;
    color: #6b7888;
    padding: 32px;
    font-size: 14px;
}

.code-cell {
    font-family: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
    font-size: 12px;
    letter-spacing: 0.03em;
    color: #d0e0f0;
}

/* ===== Status Pills ===== */

.status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    min-width: 64px;
    letter-spacing: 0.02em;
    text-transform: capitalize;
}

.status-active,
.status-running {
    background: rgba(46,125,50,0.16);
    color: #8eda92;
    border: 1px solid rgba(46,125,50,0.3);
}

.status-disabled,
.status-stopped,
.status-inactive {
    background: rgba(198,40,40,0.16);
    color: #f5a0a0;
    border: 1px solid rgba(198,40,40,0.28);
}

.status-pending,
.status-unknown {
    background: rgba(255,183,77,0.14);
    color: #f0c878;
    border: 1px solid rgba(255,183,77,0.28);
}

.status-error {
    background: rgba(229,57,53,0.2);
    color: #ff9090;
    border: 1px solid rgba(229,57,53,0.35);
}

/* ===== Log Box ===== */

.log-box {
    background: linear-gradient(180deg, rgba(5,8,13,0.95), rgba(7,10,15,0.95));
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    padding: 16px;
    overflow: auto;
    white-space: pre-wrap;
    line-height: 1.6;
    min-height: 240px;
    max-height: 480px;
    color: #c8d4e0;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 12px;
}

.log-box-tall {
    min-height: 500px;
    max-height: 72vh;
}

/* ===== Toolbar ===== */

.toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.toolbar input[type="text"] {
    max-width: 320px;
}

.toolbar-compact {
    margin-bottom: 0;
}

.table-summary {
    color: #7a8898;
    font-size: 13px;
}

/* ===== Actions ===== */

.action-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

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

.service-actions-danger {
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid rgba(255,255,255,0.08);
}

/* ===== Info Grid ===== */

.info-grid {
    display: grid;
    gap: 0;
}

.info-grid div {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.info-grid div:last-child {
    border-bottom: none;
}

.info-grid strong {
    word-break: break-all;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 13px;
    color: #e0e8f0;
}

/* ===== Empty State ===== */

.empty-state {
    padding: 28px 12px;
    color: #c0cce0;
    text-align: center;
}

.empty-state p {
    margin: 6px 0;
}

/* ===== Login ===== */

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

.login-card {
    width: min(400px, 100%);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02)),
        rgba(13,17,24,0.94);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 22px;
    padding: 32px;
    box-shadow: 0 28px 60px rgba(0,0,0,0.35);
    backdrop-filter: blur(18px);
    animation: fadeSlideUp 0.4s ease;
}

.login-badge {
    display: inline-flex;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(25,118,210,0.14);
    border: 1px solid rgba(25,118,210,0.25);
    color: #9dc9ff;
    font-size: 12px;
    margin-bottom: 14px;
}

.login-desc {
    margin: 10px 0 18px;
    color: #8a96a8;
    line-height: 1.7;
    font-size: 13px;
}

.pwd-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6b7888;
    cursor: pointer;
    font-size: 13px;
    padding: 4px 6px;
    border-radius: 6px;
    transition: color 0.15s;
}

.pwd-toggle:hover {
    color: #c0d0e0;
}

.field-pwd-wrap {
    position: relative;
}

.field-pwd-wrap input {
    padding-right: 60px;
}

/* ===== Hero Panel ===== */

.hero-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 20px 22px;
    margin-bottom: 20px;
    border-radius: 20px;
    background:
        radial-gradient(circle at top right, rgba(123,97,255,0.22), transparent 26%),
        linear-gradient(135deg, rgba(25,118,210,0.18), rgba(230,126,34,0.14)),
        rgba(16,20,28,0.88);
    border: 1px solid rgba(255,255,255,0.07);
    box-shadow: 0 16px 40px rgba(0,0,0,0.22);
    animation: fadeSlideUp 0.35s ease;
}

.hero-panel-compact {
    padding: 18px 20px;
}

.hero-kicker {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,0.07);
    font-size: 11px;
    color: #c8d8f0;
    margin-bottom: 10px;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.hero-panel h2 {
    margin: 0 0 8px;
    font-size: 26px;
    font-weight: 700;
}

.hero-panel p {
    margin: 0;
    color: #98a8ba;
    max-width: 640px;
    line-height: 1.65;
    font-size: 13px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
}

/* ===== Floating Save ===== */

.floating-save {
    position: sticky;
    bottom: 0;
    padding: 14px 0;
    margin-top: 8px;
    background: linear-gradient(180deg, transparent, rgba(9,11,16,0.95) 30%);
    z-index: 10;
    display: flex;
    justify-content: flex-end;
}

/* ===== Pay Fields Toggle ===== */

.pay-fields-hidden {
    display: none !important;
}

.pay-fields-visible {
    display: contents;
}

/* ===== Responsive: Tablet ===== */

@media (max-width: 980px) {
    .menu-toggle {
        display: flex;
    }

    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        border-right: 1px solid rgba(255,255,255,0.08);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
        opacity: 1;
    }

    .content {
        padding: 20px 16px;
        padding-top: 60px;
    }

    .grid-two,
    .form-grid-2 {
        grid-template-columns: 1fr;
    }

    .topbar,
    .hero-panel {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-meta {
        justify-content: flex-start;
    }

    .hero-panel {
        grid-template-columns: 1fr;
    }

    .cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== Responsive: Phone ===== */

@media (max-width: 640px) {
    .content {
        padding: 14px 12px;
        padding-top: 56px;
    }

    .topbar {
        padding: 14px;
    }

    .card,
    .login-card {
        padding: 16px;
        border-radius: 14px;
    }

    .topbar h1,
    .card-head h2,
    .hero-panel h2 {
        font-size: 20px;
    }

    .stat-value {
        font-size: 22px;
    }

    .hero-panel p,
    .page-subtitle {
        font-size: 12px;
    }

    .cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        min-height: 90px;
        padding: 14px;
    }

    .btn {
        padding: 9px 12px;
        font-size: 12px;
    }

    .service-actions-danger {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        padding-top: 8px;
        border-top: 1px solid rgba(255,255,255,0.06);
    }
}
