:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #fbfbfc;
    --text: #20242a;
    --muted: #6b7280;
    --line: #dfe3e8;
    --line-strong: #c5ccd6;
    --accent: #2563eb;
    --accent-2: #0f9f6e;
    --warn: #b7791f;
    --danger: #c2413a;
    --code: #111827;
    --sidebar: #1f2933;
    --sidebar-muted: #aab3bf;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

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

button,
input,
select,
textarea {
    font: inherit;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #eef1f5;
}

.login-panel {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
}

.login-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 6px;
}

.login-subtitle {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
    background: var(--sidebar);
    color: #fff;
    padding: 20px 14px;
    overflow-y: auto;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 8px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    margin-bottom: 16px;
}

.brand strong {
    display: block;
    font-size: 17px;
}

.brand span {
    display: block;
    color: var(--sidebar-muted);
    font-size: 12px;
    margin-top: 3px;
}

.nav-group {
    margin-top: 16px;
}

.nav-group-title {
    color: var(--sidebar-muted);
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 700;
    padding: 0 8px 7px;
}

.nav-link {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 6px;
    color: #e5e7eb;
    font-size: 14px;
    line-height: 1.25;
}

.nav-link span:first-child {
    min-width: 0;
    overflow-wrap: anywhere;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
}

.nav-channel-badge {
    align-self: center;
    font-size: 10px;
    padding: 2px 5px;
}

.main {
    min-width: 0;
    padding: 24px;
}

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

.page-title {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
}

.page-subtitle {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 5px;
    color: var(--muted);
    font-size: 14px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.site-lock {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #e8f4ef;
    color: #116149;
    border: 1px solid #b8ded0;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
}

.btn {
    border: 1px solid var(--line-strong);
    background: #fff;
    color: var(--text);
    border-radius: 6px;
    padding: 9px 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
}

.btn:hover {
    border-color: #9aa4b2;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-secondary {
    background: #0f9f6e;
    color: #fff;
    border-color: #0f9f6e;
}

.btn-xl {
    min-height: 52px;
    padding: 14px 22px;
    font-size: 16px;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 18px;
    align-items: start;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.panel-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.panel-title {
    font-size: 16px;
    font-weight: 800;
}

.panel-body {
    padding: 18px;
}

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

.result-summary-panel {
    margin-bottom: 18px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

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

.stat-value {
    margin-top: 8px;
    font-size: 26px;
    font-weight: 800;
}

.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.service-card {
    display: block;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fff;
}

.service-card:hover {
    border-color: var(--accent);
}

.service-name {
    font-weight: 800;
    margin-bottom: 8px;
}

.result-service {
    display: inline-block;
    font-weight: 800;
    margin-right: 6px;
    overflow-wrap: anywhere;
}

.service-meta {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

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

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

.field label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 7px;
}

.param-name {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.param-key {
    color: #111827;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.param-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.field label .param-name {
    flex: 1;
}

.field .hint {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.field .hint code {
    color: #374151;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow-wrap: anywhere;
}

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

.field textarea {
    resize: vertical;
    min-height: 90px;
}

.field input[readonly] {
    background: #eef7f2;
    color: #116149;
    font-weight: 800;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.badge-blue {
    background: #e8f0fe;
    color: #1d4ed8;
}

.badge-green {
    background: #e8f4ef;
    color: #116149;
}

.badge-gray {
    background: #eceff3;
    color: #4b5563;
}

.badge-warn {
    background: #fff5df;
    color: var(--warn);
}

.badge-red {
    background: #fdecea;
    color: var(--danger);
}

.codebox,
pre {
    margin: 0;
    border: 1px solid var(--line);
    background: var(--code);
    color: #e5e7eb;
    border-radius: 6px;
    padding: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.5;
    overflow: auto;
    min-height: 150px;
}

textarea.codebox {
    width: 100%;
    min-height: 240px;
}

.timeline {
    display: grid;
    gap: 12px;
}

.timeline-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

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

.guide-list {
    display: grid;
    gap: 10px;
    max-height: calc(100vh - 170px);
    overflow: auto;
    padding-right: 2px;
}

.parameter-summary-list {
    display: grid;
    gap: 10px;
}

.parameter-summary-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 12px;
}

.parameter-summary-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: start;
}

.parameter-summary-desc {
    margin-top: 8px;
    color: #4b5563;
    font-size: 13px;
    line-height: 1.45;
}

.guide-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 12px;
}

.guide-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: start;
}

.guide-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 5px;
}

.guide-desc {
    margin-top: 10px;
    color: #4b5563;
    font-size: 13px;
    line-height: 1.45;
}

.guide-example {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    margin-top: 9px;
    color: var(--muted);
    font-size: 12px;
}

.guide-example span {
    font-weight: 800;
}

.guide-example code {
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-2);
    color: #374151;
    padding: 2px 5px;
    overflow-wrap: anywhere;
    white-space: normal;
}

.guide-options {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 9px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.guide-options code {
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-2);
    color: #374151;
    padding: 1px 4px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

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

th {
    background: var(--surface-2);
    color: #4b5563;
    font-size: 12px;
    font-weight: 800;
}

.flash {
    border: 1px solid #b8ded0;
    background: #e8f4ef;
    color: #116149;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 700;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.form-actions-top {
    margin-top: 0;
    margin-bottom: 16px;
}

.muted {
    color: var(--muted);
}

.tech-details {
    border-top: 1px solid var(--line);
    margin-top: 12px;
    padding-top: 10px;
}

.tech-details summary {
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
}

.payload-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.payload-panel {
    min-width: 0;
}

.payload-title {
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 6px;
}

.payload-table {
    table-layout: fixed;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
}

.payload-table th {
    width: 42%;
}

.payload-table th .param-label {
    display: block;
    margin-top: 2px;
}

.payload-param-desc {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
}

.payload-table td code {
    color: #374151;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow-wrap: anywhere;
    white-space: normal;
}

.result-summary-table {
    table-layout: fixed;
}

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

.action-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.action-item summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    padding: 12px;
    font-size: 14px;
    font-weight: 800;
}

.action-form {
    border-top: 1px solid var(--line);
    padding: 12px;
}

.action-parameter-guide {
    border-top: 1px solid var(--line);
    margin-top: 12px;
    padding-top: 10px;
}

.action-parameter-guide summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    color: #374151;
    font-size: 13px;
    font-weight: 800;
}

.action-guide-list {
    display: grid;
    gap: 8px;
    max-height: 320px;
    overflow: auto;
    padding: 10px 2px 0 0;
}

.action-guide-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 10px;
}

.action-fields {
    display: grid;
    gap: 10px;
    max-height: 360px;
    overflow: auto;
    padding-right: 2px;
}

.action-fields .field label {
    align-items: flex-start;
}

.action-fields .field input,
.action-fields .field select {
    min-height: 34px;
    font-size: 13px;
}

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

    .sidebar {
        position: sticky;
        z-index: 20;
        height: auto;
        max-height: min(360px, 42vh);
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
        padding: 14px;
    }

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

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

@media (max-width: 720px) {
    .main {
        padding: 16px;
    }

    .sidebar {
        max-height: 260px;
        padding: 12px;
    }

    .brand {
        padding: 2px 6px 10px;
        margin-bottom: 10px;
    }

    .nav-group {
        margin-top: 10px;
    }

    .nav-link {
        padding: 8px;
    }

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

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