:root {
    --bg-0: #071320;
    --bg-1: #0e1f33;
    --bg-2: #132b43;
    --panel: rgba(7, 23, 40, 0.74);
    --panel-border: rgba(149, 209, 255, 0.22);
    --text: #e5f6ff;
    --muted: #9fc1d8;
    --accent: #1fd6b5;
    --accent-strong: #20f2ca;
    --warn: #ff9e69;
    --ok: #89f0a8;
    --mono: "IBM Plex Mono", monospace;
    --display: "Space Grotesk", sans-serif;
    --shadow: 0 20px 55px rgba(4, 8, 17, 0.45);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--display);
    color: var(--text);
    background: radial-gradient(1200px 700px at 12% 10%, #143b5e 0%, transparent 50%),
        radial-gradient(900px 600px at 88% 20%, #0f5060 0%, transparent 52%),
        linear-gradient(130deg, var(--bg-0), var(--bg-1) 42%, var(--bg-2));
}

.bg-glow {
    position: fixed;
    width: 38vmax;
    height: 38vmax;
    border-radius: 999px;
    filter: blur(90px);
    opacity: 0.2;
    pointer-events: none;
    z-index: 0;
    animation: drift 18s ease-in-out infinite alternate;
}

.bg-glow-a {
    top: -12vmax;
    left: -12vmax;
    background: #26f0bd;
}

.bg-glow-b {
    right: -10vmax;
    bottom: -15vmax;
    background: #2e9fff;
    animation-delay: 2s;
}

.layout {
    position: relative;
    z-index: 1;
    width: min(1080px, 94vw);
    margin: 2.2rem auto 2.5rem;
    display: grid;
    gap: 1.1rem;
}

.hero,
.panel {
    backdrop-filter: blur(14px);
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    animation: rise 480ms ease-out both;
}

.hero {
    padding: 1.5rem 1.4rem;
}

.eyebrow {
    margin: 0;
    color: var(--accent-strong);
    letter-spacing: 0.11em;
    font: 500 0.75rem/1.4 var(--mono);
    text-transform: uppercase;
}

h1 {
    margin: 0.3rem 0 0.35rem;
    font-size: clamp(1.5rem, 3.8vw, 2.35rem);
    letter-spacing: 0.01em;
}

.subtitle {
    margin: 0;
    color: var(--muted);
    max-width: 74ch;
}

.header-note {
    margin: 0.55rem 0 0;
    max-width: 86ch;
    padding: 0.42rem 0.62rem;
    border-left: 2px solid rgba(31, 214, 181, 0.62);
    border-radius: 8px;
    background: rgba(31, 214, 181, 0.08);
    color: rgba(224, 244, 255, 0.86);
    font-size: 0.79rem;
    line-height: 1.4;
}

.header-note strong {
    color: rgba(32, 242, 202, 0.9);
    font-weight: 600;
}

.panel {
    padding: 1.2rem;
}

.panel h2 {
    margin: 0 0 0.9rem;
    font-size: 1.1rem;
}

.fields-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.95rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.field-title {
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    color: #cbe5f5;
    font-size: 0.87rem;
    font-weight: 500;
}

.field-info {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.info-trigger {
    width: 1.16rem;
    height: 1.16rem;
    padding: 0;
    border-radius: 999px;
    border: 1px solid rgba(118, 190, 242, 0.52);
    background: rgba(20, 58, 87, 0.55);
    color: #bde8ff;
    font: 600 0.66rem/1 var(--mono);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    transform: none;
}

.info-trigger:hover,
.info-trigger:focus-visible {
    color: var(--accent-strong);
    border-color: rgba(31, 214, 181, 0.72);
    background: rgba(20, 58, 87, 0.7);
    box-shadow: none;
    transform: none;
}

.info-balloon {
    position: absolute;
    left: 0;
    top: calc(100% + 0.45rem);
    width: min(17.5rem, calc(100vw - 1rem));
    max-width: calc(100vw - 1rem);
    display: block;
    padding: 0.5rem 0.58rem;
    border-radius: 9px;
    border: 1px solid rgba(118, 190, 242, 0.42);
    background: rgba(4, 18, 31, 0.96);
    color: #d7f2ff;
    font: 500 0.72rem/1.36 var(--display);
    letter-spacing: 0.01em;
    box-shadow: 0 12px 26px rgba(3, 9, 17, 0.46);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity 130ms ease, transform 130ms ease, visibility 130ms ease;
    z-index: 30;
}

.info-balloon::before {
    display: none;
}

.field-info:hover .info-balloon,
.field-info:focus-within .info-balloon,
.field-info.is-open .info-balloon {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

input,
select,
button {
    border-radius: 10px;
    border: 1px solid rgba(168, 214, 255, 0.25);
    font-size: 0.95rem;
}

input,
select {
    background: rgba(6, 29, 46, 0.72);
    color: var(--text);
    padding: 0.68rem 0.76rem;
    outline: none;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 214, 181, 0.2);
}

input::placeholder {
    color: #8cb0c8;
}

.hint {
    min-height: 1rem;
    color: var(--muted);
    font-size: 0.78rem;
}

.checkbox-field {
    justify-content: flex-end;
}

.checkbox-wrap {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: #dbedf9;
    font-size: 0.9rem;
}

.checkbox-wrap input {
    inline-size: 1rem;
    block-size: 1rem;
    accent-color: var(--accent);
}

.actions {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

button {
    cursor: pointer;
    padding: 0.66rem 1rem;
    color: #031622;
    background: linear-gradient(110deg, var(--accent) 0%, var(--accent-strong) 100%);
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: transform 120ms ease, box-shadow 120ms ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(31, 214, 181, 0.3);
}

button:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
    box-shadow: none;
}

button.ghost {
    color: var(--text);
    background: rgba(28, 78, 112, 0.35);
    border: 1px solid rgba(118, 190, 242, 0.4);
}

.status {
    margin: 0.85rem 0 0;
    font: 500 0.84rem/1.45 var(--mono);
}

.status-info {
    color: #a5cdf1;
}

.status-success {
    color: var(--ok);
}

.status-error {
    color: var(--warn);
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.8rem;
}

.report-header small {
    color: var(--muted);
}

.report-header code {
    font-family: var(--mono);
    color: #b1e6ff;
}

.synthesis-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.65rem;
    margin-bottom: 0.9rem;
}

.summary-card {
    border-radius: 12px;
    border: 1px solid rgba(105, 178, 232, 0.3);
    background: rgba(5, 20, 33, 0.62);
    padding: 0.7rem 0.75rem;
}

.summary-card h3 {
    margin: 0 0 0.4rem;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #9ec7e4;
}

.summary-card p {
    margin: 0;
}

.timeframe-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.8rem;
}

.timeframe-tab {
    border-radius: 999px;
    padding: 0.42rem 0.78rem;
    border: 1px solid rgba(118, 190, 242, 0.38);
    color: #d5edfb;
    background: rgba(28, 78, 112, 0.24);
    font-weight: 600;
}

.timeframe-tab.active {
    color: #031622;
    border-color: transparent;
    background: linear-gradient(110deg, var(--accent) 0%, var(--accent-strong) 100%);
}

.timeframe-content {
    min-height: 240px;
    border-radius: 12px;
    border: 1px solid rgba(105, 178, 232, 0.3);
    background: rgba(5, 20, 33, 0.68);
    padding: 0.88rem;
}

.tf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.7rem;
}

.tf-header h3 {
    margin: 0;
}

.badge {
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font: 500 0.76rem/1.3 var(--mono);
    color: #073042;
    background: rgba(131, 235, 203, 0.95);
}

.tf-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.55rem;
    margin-bottom: 0.8rem;
}

.metric-card,
.entry-card,
.error-card {
    border-radius: 10px;
    border: 1px solid rgba(104, 178, 232, 0.25);
    background: rgba(7, 27, 44, 0.64);
    padding: 0.62rem;
}

.metric-card h4,
.entry-card h4,
.error-card h3 {
    margin: 0 0 0.35rem;
    font-size: 0.82rem;
    color: #9ac5e3;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.metric-card p,
.entry-card p,
.error-card p {
    margin: 0.2rem 0;
    color: #def2ff;
    font-size: 0.88rem;
}

.kv-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.32rem;
}

.kv-table th,
.kv-table td {
    padding: 0.2rem 0;
    text-align: left;
    vertical-align: top;
    font-size: 0.86rem;
}

.kv-table th {
    width: 40%;
    font: 500 0.74rem/1.4 var(--mono);
    color: #9ec7e4;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.kv-table td {
    color: #def2ff;
    padding-left: 0.45rem;
    word-break: break-word;
}

.kv-table tr + tr th,
.kv-table tr + tr td {
    border-top: 1px dashed rgba(118, 190, 242, 0.25);
}

.entry-kv th {
    width: 43%;
}

.entry-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    margin-bottom: 0.8rem;
}

.entry-state {
    display: inline-block;
    border-radius: 999px;
    padding: 0.12rem 0.5rem;
    font: 500 0.72rem/1.3 var(--mono);
    text-transform: uppercase;
    margin-bottom: 0.35rem;
}

.entry-state.active {
    color: #02381f;
    background: rgba(135, 242, 169, 0.95);
}

.entry-state.pending {
    color: #3e2903;
    background: rgba(255, 197, 102, 0.95);
}

.entry-state.expired,
.entry-state.none {
    color: #3f0e03;
    background: rgba(255, 158, 105, 0.95);
}

.meta {
    margin: 0.85rem 0 0.9rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.48rem 0.85rem;
}

.meta-row {
    display: grid;
    gap: 0.15rem;
}

.meta-row dt {
    font: 500 0.77rem/1.4 var(--mono);
    color: #8ab3ce;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.meta-row dd {
    margin: 0;
    color: #def2ff;
    word-break: break-word;
}

.detail-actions {
    margin-top: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
}

.detail-actions button {
    padding: 0.5rem 0.8rem;
    font-size: 0.82rem;
}

.detail-icon-actions {
    display: flex;
    gap: 0.6rem;
}

.icon-button {
    width: 2.7rem;
    height: 2.7rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-button svg {
    width: 1.34rem;
    height: 1.34rem;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.85;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-button.flash-success {
    color: #02381f;
    background: rgba(135, 242, 169, 0.95);
    border-color: rgba(135, 242, 169, 0.95);
}

.report-output {
    margin: 0.7rem 0 0;
    min-height: 260px;
    max-height: 62vh;
    overflow: auto;
    border-radius: 12px;
    border: 1px solid rgba(105, 178, 232, 0.3);
    background: rgba(5, 20, 33, 0.74);
    padding: 0.9rem;
    white-space: pre-wrap;
    font: 400 0.83rem/1.48 var(--mono);
    color: #dcf2ff;
}

#detailed-output[hidden] {
    display: none;
}

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

@keyframes drift {
    from {
        transform: translate3d(0, 0, 0);
    }
    to {
        transform: translate3d(30px, -26px, 0);
    }
}

@media (max-width: 880px) {
    .layout {
        width: min(1020px, 95vw);
    }

    .fields-grid,
    .meta,
    .synthesis-grid,
    .tf-grid,
    .entry-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .hero,
    .panel {
        border-radius: 14px;
    }

    .panel {
        padding: 1rem;
    }

    .actions {
        flex-direction: column;
    }

    .actions button {
        width: 100%;
    }

    .detail-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .field-title {
        align-items: flex-start;
    }

    .info-trigger {
        width: 1.24rem;
        height: 1.24rem;
        font-size: 0.7rem;
    }

    .detail-actions > #toggle-detail-button {
        width: 100%;
    }

    .detail-icon-actions {
        justify-content: flex-end;
        gap: 0.7rem;
    }

    .icon-button {
        width: 3rem;
        height: 3rem;
    }

    .icon-button svg {
        width: 1.5rem;
        height: 1.5rem;
    }

    .timeframe-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .timeframe-tab {
        flex: 0 0 auto;
        width: auto;
    }
}
