:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #697386;
    --line: #dbe1ea;
    --blue: #2563eb;
    --blue-strong: #1d4ed8;
    --teal: #0f766e;
    --violet: #7c3aed;
    --orange: #c2410c;
    --red: #b42318;
    --shadow: 0 10px 30px rgba(20, 31, 52, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

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

button,
input,
select {
    font: inherit;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 64px;
    padding: 0 28px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.brand,
.nav,
.account,
.button-row,
.form-actions {
    display: flex;
    align-items: center;
}

.brand {
    gap: 10px;
    font-weight: 800;
    letter-spacing: 0;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--ink);
    color: white;
    font-size: 13px;
}

.nav {
    gap: 6px;
    flex: 1;
}

.nav a {
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 650;
}

.nav a:hover {
    background: #eef2ff;
    color: var(--blue-strong);
}

.account {
    gap: 8px;
}

.account-name {
    color: var(--muted);
    font-size: 14px;
}

.page {
    width: min(1380px, calc(100% - 40px));
    margin: 28px auto 56px;
}

.toolbar-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 132px;
    padding: 28px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.toolbar-band.compact {
    min-height: 100px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--teal);
    font-size: 13px;
    font-weight: 800;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 30px;
    line-height: 1.2;
}

h2 {
    font-size: 18px;
}

.button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.16s ease;
    white-space: nowrap;
}

.button {
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    font-weight: 750;
}

.button svg,
.icon-button svg {
    width: 18px;
    height: 18px;
}

.button.primary {
    background: var(--blue);
    color: #fff;
}

.button.primary:hover {
    background: var(--blue-strong);
}

.button.ghost {
    background: #fff;
    border-color: var(--line);
    color: var(--ink);
}

.button.danger {
    background: #fff;
    border-color: #fecaca;
    color: var(--red);
}

.button.full {
    width: 100%;
}

.icon-button {
    width: 40px;
    height: 40px;
    background: #fff;
    border-color: var(--line);
}

.icon-button:hover,
.button.ghost:hover {
    background: #f8fafc;
}

.button-row {
    gap: 8px;
}

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

.metric-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric {
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
    line-height: 1.1;
}

.dashboard-grid,
.split-grid {
    display: grid;
    gap: 18px;
    margin-top: 18px;
}

.dashboard-grid {
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.75fr);
}

.split-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
}

.panel,
.form-panel,
.confirm-panel,
.auth-panel,
.empty-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    min-width: 0;
    padding: 20px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-title {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.panel-title h2 {
    margin: 0;
}

.period-switch {
    display: inline-flex;
    flex-shrink: 0;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.period-switch a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 30px;
    padding: 0 10px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

.period-switch a:hover {
    background: #ffffff;
    color: var(--ink);
}

.period-switch a.active {
    background: var(--ink);
    color: #ffffff;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

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

.trend-item {
    display: grid;
    gap: 4px;
    min-height: 92px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
}

.trend-item:hover {
    border-color: #93c5fd;
}

.trend-token {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 17px;
    font-weight: 850;
}

.trend-meta {
    color: var(--muted);
    font-size: 13px;
}

.trend-item strong {
    color: var(--orange);
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

td a {
    color: var(--blue-strong);
    font-weight: 700;
}

.empty,
.empty-panel {
    color: var(--muted);
}

.empty-panel {
    grid-column: 1 / -1;
    padding: 28px;
}

.monitor-mini-list {
    display: grid;
    gap: 10px;
}

.monitor-mini,
.monitor-card {
    display: grid;
    gap: 6px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.monitor-mini:hover,
.monitor-card:hover {
    border-color: #93c5fd;
}

.monitor-mini span,
.monitor-card p,
.monitor-card small {
    color: var(--muted);
}

.cta-box {
    display: grid;
    gap: 14px;
}

.search-surface {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 160px 160px 150px 150px 120px auto;
    gap: 12px;
    align-items: end;
    margin: 18px 0;
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.field {
    display: grid;
    gap: 6px;
}

.field label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.field.is-hidden {
    display: none;
}

.integration-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.integration-box.is-hidden {
    display: none;
}

.integration-box div {
    display: grid;
    gap: 3px;
}

.integration-box strong {
    font-size: 14px;
}

.integration-box span {
    color: var(--muted);
    font-size: 13px;
}

.tooltip-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
}

.tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 15px;
    height: 15px;
    border: 1px solid #9ca3af;
    border-radius: 50%;
    background: #fff;
    color: var(--blue-strong);
    font-size: 10px;
    font-weight: 850;
    line-height: 1;
    cursor: help;
}

.tooltip::after {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    z-index: 20;
    visibility: hidden;
    opacity: 0;
    width: min(320px, 80vw);
    padding: 10px 12px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #0f172a;
    color: #fff;
    content: attr(data-tooltip);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.45;
    transform: translateX(-50%);
    transition: opacity 0.12s ease, visibility 0.12s ease;
    white-space: normal;
}

.tooltip::before {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 3px);
    z-index: 21;
    visibility: hidden;
    opacity: 0;
    width: 8px;
    height: 8px;
    background: #0f172a;
    content: "";
    transform: translateX(-50%) rotate(45deg);
    transition: opacity 0.12s ease, visibility 0.12s ease;
}

.tooltip:hover::after,
.tooltip:focus::after,
.tooltip:hover::before,
.tooltip:focus::before {
    visibility: visible;
    opacity: 1;
}

.field input,
.field select {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
}

.checkbox-field {
    align-content: end;
}

.checkbox-field label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    color: var(--ink);
}

.checkbox-field input {
    width: 18px;
    min-height: 18px;
}

.result-summary {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 16px 0;
}

.result-summary strong {
    font-size: 22px;
}

.form-panel,
.confirm-panel,
.auth-panel {
    width: min(960px, 100%);
    margin: 18px auto 0;
    padding: 24px;
}

.auth-panel,
.confirm-panel {
    width: min(440px, 100%);
}

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

.form-actions {
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.field-errors,
.form-errors,
.errorlist {
    color: var(--red);
    font-size: 13px;
}

.errorlist {
    margin: 6px 0 0;
    padding-left: 18px;
}

.monitor-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.monitor-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.keyword {
    font-size: 22px;
    font-weight: 850;
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 800;
}

.status.on {
    background: #dcfce7;
    color: #166534;
}

.status.off {
    background: #f1f5f9;
    color: var(--muted);
}

.message-stack {
    width: min(1380px, calc(100% - 40px));
    margin: 16px auto 0;
}

.message {
    padding: 12px 14px;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    background: #f0fdf4;
    color: #166534;
}

.text-link {
    color: var(--blue-strong);
    font-weight: 750;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 18px;
}

.auth-panel p {
    display: grid;
    gap: 6px;
}

.auth-panel input {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.product-detail-card {
    display: grid;
    gap: 18px;
    margin-top: 18px;
    padding: 22px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.product-detail-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.product-detail-heading h2 {
    margin: 0;
    font-size: 22px;
}

.product-detail-heading p {
    margin: 6px 0 0;
    color: var(--muted);
}

.detail-summary-grid,
.detail-kv-grid {
    display: grid;
    gap: 0;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.detail-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.detail-summary-grid div,
.detail-kv-grid div {
    min-width: 0;
    padding: 12px 14px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.detail-summary-grid div:nth-child(3n),
.detail-kv-grid div:nth-child(2n) {
    border-right: 0;
}

.detail-summary-grid div:nth-last-child(-n + 3),
.detail-kv-grid div:nth-last-child(-n + 2) {
    border-bottom: 0;
}

.detail-summary-grid dt,
.detail-kv-grid dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.detail-summary-grid dd,
.detail-kv-grid dd {
    margin: 5px 0 0;
    overflow-wrap: anywhere;
    font-weight: 700;
}

.detail-section {
    display: grid;
    gap: 10px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.detail-section h3 {
    margin: 0;
    font-size: 17px;
}

.detail-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.detail-table {
    min-width: 560px;
}

.detail-table th {
    background: #f8fafc;
}

.detail-error {
    display: grid;
    gap: 8px;
}

.detail-error h2,
.detail-error p {
    margin: 0;
}

.modal-shell {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
}

.modal-shell.is-open {
    display: block;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
}

.modal-panel {
    position: absolute;
    left: 50%;
    top: 50%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: min(1080px, calc(100vw - 36px));
    max-height: min(860px, calc(100vh - 36px));
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.32);
    transform: translate(-50%, -50%);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 58px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.modal-header h2 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-body {
    overflow: auto;
    padding: 18px;
}

.modal-body .product-detail-card {
    margin-top: 0;
    box-shadow: none;
}

.modal-loading {
    min-height: 180px;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-weight: 750;
}

body.has-modal {
    overflow: hidden;
}

@media (max-width: 1080px) {
    .app-header {
        flex-wrap: wrap;
        min-height: auto;
        padding: 12px 18px;
    }

    .nav {
        order: 3;
        width: 100%;
        overflow-x: auto;
    }

    .metric-grid,
    .metric-grid.three,
    .dashboard-grid,
    .split-grid,
    .monitor-grid,
    .detail-summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .detail-summary-grid div:nth-child(3n) {
        border-right: 1px solid var(--line);
    }

    .detail-summary-grid div:nth-child(2n) {
        border-right: 0;
    }

    .detail-summary-grid div:nth-last-child(-n + 3) {
        border-bottom: 1px solid var(--line);
    }

    .detail-summary-grid div:nth-last-child(-n + 2) {
        border-bottom: 0;
    }

    .trend-list {
        grid-template-columns: 1fr 1fr;
    }

    .search-surface {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 720px) {
    .page,
    .message-stack {
        width: min(100% - 24px, 1380px);
    }

    .toolbar-band {
        align-items: flex-start;
        flex-direction: column;
        padding: 20px;
    }

    .panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .integration-box {
        align-items: stretch;
        flex-direction: column;
    }

    .period-switch {
        width: 100%;
    }

    .period-switch a {
        flex: 1;
    }

    h1 {
        font-size: 24px;
    }

    .metric-grid,
    .metric-grid.three,
    .dashboard-grid,
    .split-grid,
    .monitor-grid,
    .trend-list,
    .search-surface,
    .form-grid,
    .detail-summary-grid,
    .detail-kv-grid {
        grid-template-columns: 1fr;
    }

    .detail-summary-grid div,
    .detail-kv-grid div,
    .detail-summary-grid div:nth-child(2n),
    .detail-summary-grid div:nth-child(3n),
    .detail-kv-grid div:nth-child(2n) {
        border-right: 0;
    }

    .detail-summary-grid div:nth-last-child(-n + 2),
    .detail-summary-grid div:nth-last-child(-n + 3),
    .detail-kv-grid div:nth-last-child(-n + 2) {
        border-bottom: 1px solid var(--line);
    }

    .detail-summary-grid div:last-child,
    .detail-kv-grid div:last-child {
        border-bottom: 0;
    }

    .result-summary {
        align-items: flex-start;
        flex-direction: column;
    }
}
