:root {
    --bg: #f6ead8;
    --panel: #fff8ef;
    --panel-soft: #f4e4cf;
    --muted: #8a6e58;
    --line: #d8b99a;
    --text: #4b3324;
    --accent: #d68032;
    --accent-2: #b85c38;
    --success: #6d8a3a;
    --danger: #b24a3a;
    --warning: #c6852d;
    --shadow: 0 24px 60px rgba(124, 78, 36, 0.14);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(214, 128, 50, 0.16), transparent 28%),
        radial-gradient(circle at bottom right, rgba(184, 92, 56, 0.14), transparent 24%),
        var(--bg);
    color: var(--text);
}

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

.app-shell {
    width: min(1600px, calc(100vw - 24px));
    margin: 12px auto;
    padding-bottom: 20px;
}

.topbar,
.status-strip,
.panel-header,
.box,
.main-panel {
    background: rgba(255, 248, 239, 0.94);
    border: 1px solid rgba(216, 185, 154, 0.68);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.topbar {
    border-radius: 22px;
    padding: 22px 24px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-end;
}

.topbar h1 {
    margin: 0;
    font-size: 32px;
    letter-spacing: -0.03em;
}

.eyebrow {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent);
    font-size: 12px;
}

.topbar-actions {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.field-inline {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: min(520px, 48vw);
}

.status-strip {
    margin-top: 14px;
    border-radius: 20px;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.status-card {
    background: rgba(252, 241, 226, 0.9);
    border: 1px solid rgba(214, 128, 50, 0.2);
    border-radius: 16px;
    padding: 14px 16px;
}

.status-label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.status-card strong {
    display: block;
    font-size: 14px;
    word-break: break-word;
}

.main-panel {
    margin-top: 14px;
    border-radius: 22px;
    padding: 18px;
}

.panel-header {
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.panel-header h2 {
    margin: 0;
    font-size: 20px;
}

.panel-actions,
.button-row,
.tab-bar,
.input-actions,
.box-header {
    display: flex;
    gap: 10px;
    align-items: center;
}

.box-header {
    justify-content: space-between;
    margin-bottom: 10px;
}

.warning-banner {
    margin-bottom: 14px;
    border-radius: 14px;
    padding: 12px 14px;
    border: 1px solid rgba(198, 133, 45, 0.38);
    background: rgba(250, 230, 192, 0.9);
    color: #85531c;
}

.warning-banner.critical {
    border-color: rgba(178, 74, 58, 0.34);
    background: rgba(251, 228, 221, 0.92);
    color: #8a2d22;
}

.hidden {
    display: none !important;
}

.chat-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 14px;
    min-height: 900px;
}

.tab-subheader {
    margin-bottom: 14px;
}

.session-sidebar,
.chat-main {
    background: rgba(255, 251, 245, 0.92);
    border: 1px solid rgba(216, 185, 154, 0.58);
    border-radius: 18px;
    overflow: hidden;
}

.session-sidebar {
    display: flex;
    flex-direction: column;
}

.session-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(216, 185, 154, 0.42);
}

.session-sidebar-header h3 {
    margin: 0;
}

.session-list {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.session-item {
    padding: 12px;
    border-radius: 14px;
    border: 1px solid transparent;
    background: rgba(248, 236, 219, 0.86);
    cursor: pointer;
}

.session-item.active {
    border-color: rgba(214, 128, 50, 0.42);
    background: linear-gradient(135deg, rgba(240, 186, 126, 0.45), rgba(215, 135, 90, 0.28));
}

.session-item strong {
    display: block;
    font-size: 14px;
}

.session-item span {
    color: var(--muted);
    font-size: 12px;
}

.empty-state {
    color: var(--muted);
    padding: 18px;
}

.chat-main {
    display: flex;
    flex-direction: column;
}

.messages-container {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    min-height: 0;
}

.message {
    margin-bottom: 14px;
    display: flex;
}

.message.user {
    justify-content: flex-end;
}

.bubble {
    max-width: 78%;
    padding: 12px 14px;
    border-radius: 16px;
    white-space: pre-wrap;
    line-height: 1.6;
    box-shadow: 0 12px 30px rgba(124, 78, 36, 0.14);
}

.message.user .bubble {
    background: linear-gradient(135deg, rgba(224, 150, 74, 0.96), rgba(190, 95, 58, 0.94));
    color: #fffaf2;
}

.message.assistant .bubble {
    background: rgba(255, 249, 240, 0.98);
    color: #533725;
}

.message-meta {
    margin-top: 6px;
    font-size: 11px;
    color: rgba(122, 92, 69, 0.78);
}

.action-card {
    margin-top: 10px;
    border-radius: 12px;
    border: 1px solid rgba(214, 128, 50, 0.28);
    background: rgba(250, 238, 221, 0.94);
    padding: 12px;
}

.action-card p {
    margin: 0 0 8px;
    color: #6d513d;
}

.typing-indicator {
    padding: 10px 18px;
    color: var(--muted);
}

.input-row {
    border-top: 1px solid rgba(216, 185, 154, 0.42);
    padding: 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
}

.tab-bar {
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.tab-btn {
    border: 1px solid rgba(205, 170, 138, 0.5);
    background: rgba(252, 241, 226, 0.92);
    color: var(--muted);
    border-radius: 999px;
    padding: 9px 14px;
    cursor: pointer;
}

.tab-btn.active {
    background: linear-gradient(135deg, rgba(240, 186, 126, 0.48), rgba(215, 135, 90, 0.32));
    color: var(--text);
    border-color: rgba(214, 128, 50, 0.48);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.stack-grid {
    display: grid;
    gap: 14px;
    margin-bottom: 14px;
}

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

.compact-grid {
    gap: 10px;
}

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

.box {
    border-radius: 18px;
    padding: 16px;
}

.box h3 {
    margin: 0 0 10px;
    font-size: 18px;
}

.box p {
    line-height: 1.6;
}

label {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 10px;
}

input,
textarea,
select,
pre.output {
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(216, 185, 154, 0.58);
    background: rgba(255, 252, 247, 0.98);
    color: var(--text);
    padding: 12px 13px;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: rgba(214, 128, 50, 0.62);
    box-shadow: 0 0 0 3px rgba(214, 128, 50, 0.12);
}

.helper-text,
code {
    color: var(--muted);
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
    border-radius: 12px;
    border: 1px solid transparent;
    padding: 10px 14px;
    cursor: pointer;
    color: var(--text);
}

.primary-btn {
    background: linear-gradient(135deg, rgba(214, 128, 50, 0.95), rgba(184, 92, 56, 0.95));
    color: #fff7ef;
    font-weight: 700;
}

.secondary-btn {
    background: rgba(247, 233, 214, 0.95);
    border-color: rgba(214, 128, 50, 0.32);
}

.ghost-btn {
    background: rgba(255, 248, 239, 0.5);
    border-color: rgba(184, 92, 56, 0.26);
}

.small-btn {
    padding: 8px 12px;
    font-size: 13px;
}

button:disabled {
    opacity: 0.58;
    cursor: not-allowed;
    filter: saturate(0.7);
}

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

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

th,
td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid rgba(216, 185, 154, 0.42);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

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

.output {
    min-height: 120px;
    margin: 0;
    white-space: pre-wrap;
    overflow: auto;
    font-size: 12px;
    line-height: 1.6;
}

.tall-output {
    height: 420px;
    min-height: 420px;
}

.large-output {
    min-height: 720px;
}

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

.metric-grid div {
    border-radius: 14px;
    background: rgba(253, 243, 231, 0.96);
    padding: 12px;
    border: 1px solid rgba(216, 185, 154, 0.44);
}

.metric-grid span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

.metric-grid strong {
    display: block;
    font-size: 18px;
}

.stripe-card-container {
    border: 1px dashed rgba(214, 128, 50, 0.45);
    padding: 12px;
    border-radius: 12px;
}

.stripe-card {
    min-height: 40px;
}

.notification-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification-item {
    padding: 12px;
    border-radius: 14px;
    background: rgba(255, 248, 239, 0.98);
    border: 1px solid rgba(216, 185, 154, 0.52);
    width: 100%;
    text-align: left;
    color: var(--text);
    cursor: pointer;
}

.notification-item.unread {
    border-color: rgba(214, 128, 50, 0.56);
}

.notification-item h4 {
    margin: 0 0 6px;
}

.notification-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 12px;
    margin-top: 8px;
}

.toast-container {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 50;
}

.toast {
    width: min(360px, calc(100vw - 32px));
    padding: 14px;
    border-radius: 16px;
    background: rgba(255, 248, 239, 0.98);
    color: var(--text);
    border: 1px solid rgba(214, 128, 50, 0.38);
    box-shadow: var(--shadow);
    cursor: pointer;
    text-align: left;
}

.toast strong {
    display: block;
    margin-bottom: 6px;
}

.toast .button-row {
    margin-top: 10px;
}

.lines-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.span-two {
    grid-column: span 2;
}

.report-title-cell {
    font-weight: 600;
    margin-bottom: 4px;
}

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

.status-badge {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid transparent;
}

.status-badge.pending {
    background: rgba(239, 198, 128, 0.3);
    color: #8a5317;
    border-color: rgba(198, 133, 45, 0.42);
}

.status-badge.preview {
    background: rgba(226, 176, 116, 0.24);
    color: #8d4e20;
    border-color: rgba(214, 128, 50, 0.36);
}

.status-badge.success {
    background: rgba(184, 205, 136, 0.3);
    color: #4f6224;
    border-color: rgba(109, 138, 58, 0.4);
}

.status-badge.failed {
    background: rgba(226, 164, 154, 0.28);
    color: #8d3328;
    border-color: rgba(178, 74, 58, 0.36);
}

.status-badge.neutral {
    background: rgba(215, 194, 170, 0.22);
    color: #705845;
    border-color: rgba(138, 110, 88, 0.28);
}

.status-hint {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

button.session-item {
    width: 100%;
    text-align: left;
    color: inherit;
    border: 1px solid transparent;
}

@media (max-width: 1240px) {
    .chat-layout {
        min-height: 680px;
    }
}

@media (max-width: 960px) {
    .status-strip,
    .stack-grid.two-col,
    .metric-grid {
        grid-template-columns: 1fr;
    }

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

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

    .field-inline {
        min-width: 0;
    }

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

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

    .span-two {
        grid-column: auto;
    }
}
