:root {
    color-scheme: dark;
    --bg: #06111f;
    --bg-soft: #091829;
    --panel: rgba(7, 18, 31, 0.92);
    --panel-strong: rgba(6, 14, 25, 0.96);
    --border: rgba(76, 169, 255, 0.16);
    --border-strong: rgba(76, 169, 255, 0.32);
    --muted: #8db6d8;
    --text: #edf7ff;
    --green: #21d796;
    --amber: #f5b548;
    --purple: #af7cff;
    --blue: #58a9ff;
    --red: #ff6e8c;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 30% 0%, rgba(52, 134, 255, 0.23), transparent 32%),
        radial-gradient(circle at 100% 10%, rgba(0, 119, 255, 0.14), transparent 26%),
        linear-gradient(180deg, rgba(4, 10, 18, 0.6), rgba(4, 10, 18, 0.92)),
        repeating-linear-gradient(90deg, transparent 0 129px, rgba(255,255,255,.018) 130px),
        repeating-linear-gradient(0deg, transparent 0 91px, rgba(255,255,255,.012) 92px),
        var(--bg);
    background-attachment: fixed;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .32;
    background:
        linear-gradient(120deg, transparent 0 22%, rgba(67, 151, 255, .08) 22.2%, transparent 22.4%),
        linear-gradient(24deg, transparent 0 68%, rgba(67, 151, 255, .07) 68.2%, transparent 68.4%);
}

button, input, select, textarea { font: inherit; }
button, select { -webkit-tap-highlight-color: transparent; }

a { color: inherit; }
.page-shell { width: min(1680px, calc(100% - 28px)); margin: 0 auto; padding: 18px 0 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.brand-wrap { display: flex; gap: 13px; align-items: center; }
.brand-icon, .home-button {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(25, 85, 140, 0.34), rgba(8, 22, 38, 0.76));
    color: #dff3ff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.brand-icon { font-size: 21px; font-weight: 900; }
.home-button { text-decoration: none; font-size: 19px; }
.topbar h1 { margin: 0; font-size: clamp(28px, 3.4vw, 34px); line-height: 1.05; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

.app-grid { display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 16px; align-items: start; }
.panel {
    border: 1px solid var(--border);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(7, 18, 31, .92), rgba(5, 13, 24, .96));
    box-shadow: var(--shadow);
    overflow: hidden;
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-head span { color: var(--muted); font-size: 13px; }
.panel-body { padding: 18px; }
.field-label, .field-group > span {
    display: block;
    margin-bottom: 10px;
    color: #cde6fb;
    font-size: 14px;
    font-weight: 700;
}
textarea, select, input[type="search"] {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #020914;
    color: var(--text);
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}
textarea:focus, select:focus, input[type="search"]:focus {
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px rgba(88, 169, 255, 0.09);
}
textarea {
    min-height: 322px;
    resize: vertical;
    padding: 16px;
    line-height: 1.5;
}
select, input[type="search"] { padding: 13px 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.action-row, .view-actions, .search-row { display: flex; flex-wrap: wrap; gap: 10px; }
.action-row { margin-top: 16px; }
.button {
    padding: 11px 16px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 14px;
    background: rgba(255,255,255,.04);
    color: #e5f3ff;
    font-weight: 800;
    cursor: pointer;
    transition: transform .12s ease, border-color .18s ease, background .18s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--border-strong); background: rgba(88, 169, 255, .08); }
.button:disabled { opacity: .46; cursor: not-allowed; }
.button.primary, .tab-active {
    border-color: rgba(88, 169, 255, .48);
    background: linear-gradient(180deg, rgba(61, 169, 255, .26), rgba(29, 99, 175, .34));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.export-button { margin-left: auto; }
.progress-card {
    margin-top: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px;
    background: rgba(255,255,255,.02);
}
.progress-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 10px; }
.status-dot-row { display: flex; align-items: center; gap: 10px; }
.status-dot { width: 9px; height: 9px; border-radius: 999px; background: #49b8ff; box-shadow: 0 0 14px rgba(73,184,255,.7); }
.progress-track { height: 8px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden; }
#progressBar { width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #2993ff, #49d1ff); transition: width .2s ease; }
.progress-percent {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 47px;
    padding: 4px 8px;
    margin-left: 10px;
    border-radius: 999px;
    background: rgba(88,169,255,.12);
    border: 1px solid var(--border);
    color: #d8efff;
    font-size: 12px;
}
.progress-card p { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 12px; }
.stat-card {
    min-height: 86px;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px 16px;
    background: rgba(255,255,255,.02);
}
.stat-card strong { display: block; font-size: 22px; margin-bottom: 4px; }
.stat-card span { color: var(--muted); font-size: 13px; }
.view-actions { margin-top: 16px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 13px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.09);
    background: rgba(255,255,255,.02);
    color: #eaf6ff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
}
.chip span {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    background: rgba(255,255,255,.05);
    font-size: 12px;
}
.chip.active, .chip:hover { border-color: var(--border-strong); background: rgba(88,169,255,.11); }
.chip.success { color: #6ef1c4; }
.chip.warning, .chip.amber { color: #f7c366; }
.chip.error { color: #ff94aa; }
.chip.purple { color: #c8a4ff; }
.chip.blue { color: #8dccff; }
.search-row { margin-top: 16px; align-items: center; }
.search-box { position: relative; flex: 1 1 340px; }
.search-box span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.switch-label { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 700; }
.switch-label input { display: none; }
.switch-label i {
    position: relative;
    width: 52px;
    height: 28px;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    border: 1px solid var(--border);
    display: inline-block;
}
.switch-label i::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #dcefff;
    transition: transform .18s ease;
}
.switch-label input:checked + i { background: rgba(88,169,255,.18); border-color: var(--border-strong); }
.switch-label input:checked + i::after { transform: translateX(22px); }
.view-block { margin-top: 16px; }
.hidden { display: none; }
.table-wrap {
    overflow: auto;
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 18px;
    background: rgba(0,0,0,.08);
}
.table-wrap::-webkit-scrollbar, .chain-canvas::-webkit-scrollbar { height: 10px; width: 10px; }
.table-wrap::-webkit-scrollbar-thumb, .chain-canvas::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 999px; }
.table-wrap::-webkit-scrollbar-track, .chain-canvas::-webkit-scrollbar-track { background: rgba(255,255,255,.04); }
table { width: 100%; min-width: 1120px; border-collapse: collapse; }
thead th {
    padding: 14px 12px;
    text-align: left;
    font-size: 13px;
    color: #d9ecff;
    border-bottom: 1px solid rgba(255,255,255,.08);
    background: rgba(8, 17, 30, .92);
    position: sticky;
    top: 0;
    z-index: 1;
}
thead th small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}
tbody td {
    padding: 14px 12px;
    border-bottom: 1px solid rgba(255,255,255,.05);
    vertical-align: top;
    font-size: 13px;
}
tbody tr { cursor: pointer; transition: background .16s ease; }
tbody tr:hover { background: rgba(88,169,255,.05); }
tbody tr.active-row { background: rgba(88,169,255,.1); box-shadow: inset 2px 0 0 rgba(88,169,255,.9); }
.empty-row td { text-align: center; color: var(--muted); cursor: default; }
.domain-title { font-size: 14px; font-weight: 800; color: #eff8ff; word-break: break-word; }
.domain-meta, .ns-lines, .ip-lines, .step-meta, .detail-hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.domain-link { display: block; color: #a9d4ff; margin-top: 4px; word-break: break-word; }
.ns-lines, .ip-lines { white-space: normal; word-break: break-word; }
.code-pill, .status-pill, .mini-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.08);
    font-weight: 800;
    font-size: 12px;
}
.code-pill.ok, .status-pill.ok, .mini-badge.ok { color: #7ef6c8; background: rgba(33,215,150,.10); }
.code-pill.warning, .status-pill.warning, .mini-badge.warning { color: #ffd27f; background: rgba(245,181,72,.10); }
.code-pill.error, .status-pill.error, .mini-badge.error { color: #ff9bb0; background: rgba(255,110,140,.10); }
.redirect-stack { display: flex; flex-direction: column; gap: 6px; }
.redirect-stack strong { font-size: 16px; }
.status-stack { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.detail-box, .chain-canvas {
    margin-top: 16px;
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 18px;
    padding: 18px;
    background: rgba(0,0,0,.08);
    min-height: 108px;
}
.detail-content { display: grid; gap: 16px; }
.detail-title { font-size: 18px; font-weight: 900; }
.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 12px;
}
.summary-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    background: rgba(255,255,255,.02);
}
.summary-card span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.summary-card strong, .summary-card div { display: block; word-break: break-word; }
.chain-list { display: grid; gap: 12px; }
.chain-step {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    padding: 14px;
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 16px;
    background: rgba(255,255,255,.02);
}
.step-url { font-size: 14px; font-weight: 800; word-break: break-word; }
.step-location {
    margin-top: 6px;
    color: #9ed1ff;
    font-size: 12px;
    word-break: break-word;
}
.chain-arrow { color: #97caff; font-size: 20px; line-height: 1; margin-top: 4px; }
.toast {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 50;
    padding: 12px 16px;
    border-radius: 14px;
    background: rgba(10,20,32,.95);
    color: #e7f4ff;
    border: 1px solid var(--border-strong);
    transform: translateY(18px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255,110,140,.28); }

@media (max-width: 1240px) {
    .app-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
    .summary-cards { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
}

@media (max-width: 720px) {
    .page-shell { width: min(100%, calc(100% - 18px)); padding-top: 12px; }
    .topbar { align-items: flex-start; }
    .app-grid, .form-grid, .stats-grid, .summary-cards { grid-template-columns: 1fr; }
    .panel-head, .panel-body { padding: 14px; }
    .search-row, .view-actions, .action-row { flex-direction: column; align-items: stretch; }
    .export-button { margin-left: 0; }
    .switch-label { justify-content: space-between; }
    textarea { min-height: 220px; }
}

.ns-load-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 6px 10px;
    border: 1px solid rgba(88, 169, 255, 0.28);
    border-radius: 10px;
    background: rgba(88, 169, 255, 0.08);
    color: #a9d8ff;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
}

.ns-load-button:hover {
    border-color: rgba(88, 169, 255, 0.52);
    background: rgba(88, 169, 255, 0.16);
    color: #ffffff;
}

/* v1.0.8 performance overrides */
html { background: #06111f; }
body {
    background: linear-gradient(180deg, #071522 0%, #050d18 100%);
    background-attachment: scroll;
    text-rendering: optimizeSpeed;
}
body::before { display: none; }
.panel {
    box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
    contain: layout paint;
}
.table-wrap,
.detail-box,
.chain-canvas {
    contain: layout paint;
}
tbody tr { transition: none; }
.detail-content,
.chain-list {
    content-visibility: auto;
    contain-intrinsic-size: 320px;
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* v2.2 custom dropdown seperti Caplin Gallery */
.native-select {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    width: 100%;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    background: #020914;
    cursor: pointer;
    text-align: left;
    outline: none;
}

.custom-select-trigger:hover {
    border-color: rgba(88, 169, 255, .30);
    background: #04101d;
}

.custom-select.open .custom-select-trigger,
.custom-select-trigger:focus-visible {
    border-color: #39aefc;
    box-shadow: 0 0 0 3px rgba(57, 174, 252, .10);
}

.custom-select-value {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.custom-select-selected-icon,
.custom-select-option-icon {
    flex: 0 0 26px;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: #7fd1ff;
    background: rgba(56, 167, 242, .09);
    font-size: 12px;
    font-weight: 900;
}

.custom-select-arrow {
    flex: 0 0 auto;
    color: #62c8ff;
    font-size: 13px;
    transition: transform .15s ease;
}

.custom-select.open .custom-select-arrow {
    transform: rotate(180deg);
}

.custom-select-menu {
    position: absolute;
    top: calc(100% + 7px);
    left: 0;
    right: 0;
    z-index: 60;
    display: none;
    max-height: 230px;
    overflow-y: auto;
    padding: 7px;
    border: 1px solid rgba(61, 174, 246, .22);
    border-radius: 14px;
    background: #020a13;
    box-shadow: 0 16px 34px rgba(0, 0, 0, .42);
}

.custom-select.open .custom-select-menu {
    display: block;
}

.custom-select-menu::-webkit-scrollbar {
    width: 7px;
}

.custom-select-menu::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(83, 182, 246, .25);
}

.custom-select-option {
    width: 100%;
    min-height: 43px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border: 0;
    border-radius: 10px;
    color: #b8c8d7;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.custom-select-option:hover,
.custom-select-option:focus-visible {
    color: #ffffff;
    background: rgba(35, 132, 199, .14);
    outline: none;
}

.custom-select-option.selected {
    color: #ffffff;
    background: #0b2d47;
}

.custom-select-option.selected .custom-select-option-icon {
    color: #a7e3ff;
    background: rgba(72, 184, 255, .15);
}

.custom-select-option-label {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.input-panel {
    position: relative;
    z-index: 5;
}

@media (max-width: 720px) {
    .custom-select-trigger {
        min-height: 50px;
    }
}

/* v2.3 fix dropdown terpotong */
.app-grid {
    grid-template-columns: 440px minmax(0, 1fr);
}

.input-panel {
    position: relative;
    z-index: 40;
    overflow: visible;
    contain: none;
}

.input-panel .panel-head {
    border-radius: 22px 22px 0 0;
    background: linear-gradient(180deg, rgba(7, 18, 31, .98), rgba(6, 16, 28, .98));
}

.input-panel .panel-body {
    border-radius: 0 0 22px 22px;
    background: linear-gradient(180deg, rgba(7, 18, 31, .98), rgba(5, 13, 24, .98));
}

.result-panel {
    position: relative;
    z-index: 1;
}

.form-grid,
.field-group,
.custom-select {
    min-width: 0;
    position: relative;
}

.custom-select.open {
    z-index: 1000;
}

.custom-select-trigger {
    min-height: 50px;
    gap: 8px;
    padding: 0 10px;
    font-size: 14px;
}

.custom-select-selected-icon,
.custom-select-option-icon {
    flex-basis: 24px;
    width: 24px;
    height: 24px;
}

.custom-select-value {
    flex: 1 1 auto;
    gap: 8px;
}

.custom-select-value .custom-select-option-label {
    flex: 1 1 auto;
}

.custom-select-menu {
    left: 0;
    right: auto;
    width: max-content;
    min-width: max(100%, 230px);
    max-width: min(300px, calc(100vw - 28px));
    z-index: 2000;
}

.form-grid > .field-group:nth-child(even) .custom-select-menu {
    left: auto;
    right: 0;
}

.custom-select-option {
    min-width: 214px;
    white-space: nowrap;
}

@media (max-width: 1240px) {
    .app-grid {
        grid-template-columns: 1fr;
    }

    .custom-select-menu,
    .form-grid > .field-group:nth-child(even) .custom-select-menu {
        left: 0;
        right: auto;
    }
}

@media (max-width: 720px) {
    .input-panel {
        overflow: visible;
    }

    .custom-select-menu,
    .form-grid > .field-group:nth-child(even) .custom-select-menu {
        left: 0;
        right: auto;
        width: 100%;
        min-width: 100%;
        max-width: 100%;
    }

    .custom-select-option {
        min-width: 0;
    }
}
