:root {
    --bg: #f5f6f8;
    --primary: #f6821f;
    --accent: #f6821f;
    --ink: #0f172a;
    --muted: #475569;
    --panel: #ffffff;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --blue: #1f4fd6;
    --blue-light: #e8edfb;
    --radius: 6px;
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    min-height: 100vh;
    color: var(--ink);
    padding: 32px 14px 56px;
}

.page {
    max-width: 1180px;
    margin: 0 auto;
}

.hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.eyebrow {
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 12px;
    margin: 0 0 6px;
    color: var(--primary);
}

h1 {
    margin: 0;
    font-size: 32px;
}

.lede {
    margin: 8px 0 0;
    color: var(--muted);
    max-width: 720px;
    line-height: 1.5;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #0f172a;
    border: 1px solid #bae6fd;
    font-weight: 600;
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #0f172a;
    font-size: 14px;
}

input[type="text"],
input[type="number"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: 12px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #f8fafc;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(31, 79, 214, 0.15);
    background: #fff;
}

textarea {
    min-height: 110px;
    resize: vertical;
    font-family: 'SFMono-Regular', Consolas, Monaco, 'Courier New', monospace;
}

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

.switch-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.switch-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
    font-size: 14px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 4px rgba(246, 130, 31, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px dashed var(--border);
}

.btn-quiet {
    background: #0f172a;
    color: #f8fafc;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.24);
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.status {
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-top: 12px;
    border: 1px solid transparent;
    font-size: 14px;
}

.status.success {
    background: #ecfeff;
    color: #0f172a;
    border-color: #a5f3fc;
}

.status.error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecdd3;
}

.status.info {
    background: var(--blue-light);
    color: #312e81;
    border-color: #c7d2fe;
}

.prompt-preview {
    background: #1e293b;
    color: #e2e8f0;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 12.5px;
    line-height: 1.6;
    padding: 16px;
    border-radius: var(--radius);
    max-height: 420px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid #334155;
}

.char-counter {
    text-align: right;
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.char-counter.warn {
    color: #dc2626;
    font-weight: 600;
}

.prompt-output-panel {
    margin-top: 14px;
}

.prompt-output-panel summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    padding: 6px 0;
    user-select: none;
}

.prompt-test-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: end;
}

.tenant-table {
    display: grid;
    gap: 12px;
}

.tenant-row {
    display: grid;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

.tenant-row__top {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
}

.tenant-row__bottom {
    display: grid;
    grid-template-columns: 0.3fr 0.3fr 1.4fr;
    align-items: center;
    gap: 12px;
}

.tenant-features {
    font-size: 13px;
    color: var(--muted);
    grid-column: 1 / -1;
}

.tenant-name {
    font-weight: 700;
    margin: 0 0 4px;
}

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

.tag {
    display: inline-block;
    background: var(--blue-light);
    color: #0f172a;
    border: 1px solid #c7d2fe;
    padding: 4px 8px;
    border-radius: var(--radius);
    font-size: 12px;
    margin-right: 6px;
}

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

.copy-token {
    background: none;
    border: none;
    padding: 0;
    color: #0ea5e9;
    cursor: pointer;
    text-decoration: underline;
    font-weight: 600;
}

.mono {
    font-family: 'SFMono-Regular', Consolas, Monaco, 'Courier New', monospace;
    font-size: 13px;
}

.callout {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: #fffbeb;
    border: 1px dashed var(--primary);
    color: #92400e;
    font-size: 13px;
    line-height: 1.5;
}

.files-table {
    display: grid;
    gap: 12px;
}

.file-row {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    background: #f8fafc;
}

.file-row h4 {
    margin: 0 0 4px;
}

.file-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--muted);
}

.upload-card {
    margin-top: 0;
}

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

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 16px;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--border);
    width: min(860px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.32);
}

.upload-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-top: 12px;
    background: #f8fafc;
}

.upload-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.badge {
    display: inline-flex;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    background: #e0f2fe;
    border-radius: 50%;
    font-weight: 700;
    color: #0f172a;
}

.progress-log {
    margin-top: 12px;
    max-height: 240px;
    overflow-y: auto;
    background: #0f172a;
    color: #e0f2fe;
    border-radius: var(--radius);
    border: 1px solid #1f2937;
    font-family: 'SFMono-Regular', Consolas, Monaco, 'Courier New', monospace;
    font-size: 12px;
    padding: 12px 14px;
}

.progress-line {
    padding: 4px 0;
    border-bottom: 1px solid #1f2937;
}

.progress-line:last-child {
    border-bottom: none;
}

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

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

    .tenant-row {
        align-items: flex-start;
    }

    .tenant-row__top,
    .tenant-row__bottom {
        grid-template-columns: 1fr;
    }

    .actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}
