* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #1a1a1a;
    line-height: 1.5;
}

/* Navbar */
.navbar {
    background: #1a1a2e;
    color: #fff;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    color: #ccc;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.nav-link:hover {
    color: #fff;
}

.nav-logout {
    color: #e74c3c;
}

/* Container */
.container {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: #1a1a2e;
}

h2 {
    font-size: 1.2rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #333;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background: #fff;
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.metric-card.accent {
    background: #1a1a2e;
    color: #fff;
}

.metric-card.accent .metric-label {
    color: #aaa;
}

.metric-card.small {
    padding: 0.75rem;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.metric-card.small .metric-value {
    font-size: 1.25rem;
}

.metric-label {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.data-table thead {
    background: #f0f0f0;
}

.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
    font-weight: 600;
}

.data-table td {
    padding: 0.6rem 1rem;
    border-top: 1px solid #eee;
    font-size: 0.9rem;
}

.data-table code {
    background: #f0f0f0;
    padding: 0.15em 0.4em;
    border-radius: 3px;
    font-size: 0.85em;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 2rem !important;
}

/* Bars */
.bar {
    background: #4a9eff;
    border-radius: 3px;
    min-width: 4px;
    height: 20px;
    transition: width 0.3s;
}

.accent-bar {
    background: #2ecc71;
}

.chart-container {
    margin-bottom: 1rem;
}

/* Login */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    gap: 1rem;
}

.login-container h1 {
    font-size: 2rem;
    color: #1a1a2e;
}

.login-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.login-form input {
    padding: 0.6rem 1rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    width: 250px;
}

.login-form button {
    padding: 0.6rem 1.5rem;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
}

.login-form button:hover {
    background: #2a2a4e;
}

.login-widget {
    margin-top: 0.5rem;
}

/* Settings form */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.settings-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

/* Preset sections */
.preset-section {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #eee;
}

.form-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.form-input:focus {
    outline: none;
    border-color: #1a1a2e;
    box-shadow: 0 0 0 2px rgba(26, 26, 46, 0.1);
}

.form-input-short {
    max-width: 150px;
}

/* Parameter grid */
.param-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
}

.param-field {
    display: flex;
    flex-direction: column;
}

.param-field label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0.25rem;
}

.param-field .form-input {
    margin-bottom: 0.15rem;
}

.param-range {
    font-size: 0.7rem;
    color: #999;
    margin-bottom: 0.25rem;
}

.form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 0.5rem;
}

.form-hint {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 1rem;
}

.btn {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-size: 0.9rem;
    text-decoration: none;
    border: 1px solid #ccc;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background: #f0f0f0;
}

.btn-primary {
    background: #1a1a2e;
    color: #fff;
    border-color: #1a1a2e;
}

.btn-primary:hover {
    background: #2a2a4e;
}

.btn-active {
    background: #1a1a2e;
    color: #fff;
    border-color: #1a1a2e;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
}

.btn-danger {
    background: #e74c3c;
    color: #fff;
    border-color: #e74c3c;
}

.btn-danger:hover {
    background: #c0392b;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Detail table */
.detail-table th {
    width: 150px;
    vertical-align: top;
    background: #fafafa;
}

.detail-table td {
    word-break: break-word;
}

.pre-wrap {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    font-size: 0.85rem;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

/* ── Public Header / Footer ───────────────────────────────── */

.public-header {
    background: #1a1a2e;
    color: #fff;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.public-brand {
    font-weight: 700;
    font-size: 1.1rem;
}

.public-footer {
    text-align: center;
    padding: 2rem 0;
    color: #999;
    font-size: 0.85rem;
}

/* ── Streaming Container ──────────────────────────────────── */

.stream-container {
    position: relative;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    min-height: 200px;
    max-height: 600px;
    overflow-y: auto;
}

.stream-text {
    padding: 1.5rem;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.9rem;
    line-height: 1.6;
}

.stream-text h1,
.stream-text h2,
.stream-text h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.stream-text h1 { font-size: 1.4rem; }
.stream-text h2 { font-size: 1.15rem; }
.stream-text h3 { font-size: 1rem; }

.stream-text ul,
.stream-text ol {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.stream-text table {
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.85rem;
    width: 100%;
}

.stream-text th,
.stream-text td {
    border: 1px solid #ddd;
    padding: 0.4rem 0.75rem;
    text-align: left;
}

.stream-text th {
    background: #f0f0f0;
    font-weight: 600;
}

.stream-text code {
    background: #f4f4f5;
    padding: 0.1em 0.35em;
    border-radius: 3px;
    font-size: 0.85em;
}

.stream-text pre {
    background: #f4f4f5;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.stream-overlay {
    position: absolute;
    inset: 0;
    background: rgba(26, 26, 46, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    z-index: 10;
}

/* ── Spinner ──────────────────────────────────────────────── */

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Result Actions ───────────────────────────────────────── */

.result-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.feedback-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-feedback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    font-size: 1.25rem;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.btn-feedback:hover {
    background: #f0f0f0;
    border-color: #999;
}

.btn-feedback:disabled {
    opacity: 0.5;
    cursor: default;
}

/* ── Error Alert ──────────────────────────────────────────── */

.alert-error {
    background: #fde8e8;
    color: #c0392b;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* ── Streaming: scroll lock during loading ───────────────── */

.stream-container.loading {
    overflow: hidden;
}

/* ── Completion Banner ───────────────────────────────────── */

.stream-done-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: #2ecc71;
    color: #fff;
    text-align: center;
    padding: 0.6rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 8px 8px 0 0;
    z-index: 20;
    animation: fadeInOut 3s ease forwards;
    pointer-events: none;
}

@keyframes fadeInOut {
    0%   { opacity: 0; }
    10%  { opacity: 1; }
    80%  { opacity: 1; }
    100% { opacity: 0; }
}

/* ── Overlay Fade-out ────────────────────────────────────── */

.stream-overlay {
    transition: opacity 0.4s ease, backdrop-filter 0.6s ease, -webkit-backdrop-filter 0.6s ease;
}

.stream-overlay.frosted {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(26, 26, 46, 0.3);
}

.stream-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* ── Language Switcher ───────────────────────────────────── */

.lang-switcher {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.lang-switcher a {
    color: #999;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
    transition: color 0.2s;
}

.lang-switcher a.active {
    color: #fff;
    font-weight: 700;
}

.lang-switcher a:hover {
    color: #ccc;
}
