/* Polaris Web UI — Dark theme */
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    line-height: 1.6;
}
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
}
header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-bottom: 1px solid #334155;
    padding: 1.5rem 0 0;
    margin-bottom: 2rem;
}
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
h1 {
    margin: 0;
    font-size: 1.5rem;
    color: #f1f5f9;
}
.user-info {
    font-size: 0.85rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.logout-btn {
    padding: 0.25rem 0.75rem;
    background: #334155;
    color: #e2e8f0;
    text-decoration: none;
    border-radius: 0.35rem;
    font-size: 0.8rem;
    transition: background 0.2s;
}
.logout-btn:hover {
    background: #dc2626;
    color: #fff;
}

/* Schedule field layout */
.schedule-fields {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin-top: 0.5rem;
}
.field {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}
.field-label {
    flex-shrink: 0;
    width: 110px;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 500;
    padding-top: 0.1rem;
}
.field-value {
    flex: 1;
    color: #e2e8f0;
}
.field-value.topic {
    font-weight: 500;
    color: #fbbf24;
}
.field-value.notes {
    color: #cbd5e1;
    white-space: pre-wrap;
    padding-left: 0.75rem;
    border-left: 2px solid #334155;
    font-size: 0.9rem;
}
.field-value .muted {
    color: #64748b;
}
.field-value code {
    background: #0f172a;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    color: #22d3ee;
    font-size: 0.85rem;
}
.field-value .tz {
    color: #64748b;
    font-size: 0.85rem;
}
.field-small .field-label,
.field-small .field-value {
    font-size: 0.8rem;
    color: #64748b;
}

/* ── Sessions dashboard ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    padding: 0.85rem 1rem;
    text-align: center;
}
.stat-label {
    color: #94a3b8;
    font-size: 0.78rem;
    margin-bottom: 0.35rem;
}
.stat-value {
    color: #fbbf24;
    font-size: 1.35rem;
    font-weight: 600;
}
.stat-value-small {
    color: #22d3ee;
    font-size: 0.8rem;
    font-family: ui-monospace, monospace;
    word-break: break-all;
    line-height: 1.3;
}

/* Tool chips */
.tool-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.tool-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 999px;
    padding: 0.3rem 0.75rem;
    font-size: 0.82rem;
}
.tool-name { color: #cbd5e1; }
.tool-count {
    background: #fbbf24;
    color: #0f172a;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

/* Source filter */
.source-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.src-tag {
    padding: 0.3rem 0.75rem;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 999px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.85rem;
}
.src-tag.active {
    background: #fbbf24;
    color: #0f172a;
    border-color: #fbbf24;
}
.src-tag .count {
    margin-left: 0.3rem;
    background: #334155;
    color: #94a3b8;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.7rem;
}
.src-tag.active .count {
    background: #0f172a;
    color: #fbbf24;
}

/* Session cards */
.session-card {
    display: block;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
    text-decoration: none;
    color: #e2e8f0;
    transition: border-color 0.2s, transform 0.1s;
}
.session-card:hover {
    border-color: #fbbf24;
    transform: translateY(-1px);
}
.session-card.active {
    border-left: 3px solid #22c55e;
}
.session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.session-title {
    font-weight: 500;
    color: #f1f5f9;
}
.session-badge {
    background: #312e81;
    color: #c7d2fe;
    padding: 0.1rem 0.5rem;
    border-radius: 0.3rem;
    font-size: 0.72rem;
    text-transform: uppercase;
}
.session-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.82rem;
    color: #94a3b8;
}
.session-model {
    color: #64748b;
    font-family: ui-monospace, monospace;
    font-size: 0.75rem;
    margin-left: auto;
}

/* Session detail page */
.back-link {
    display: inline-block;
    color: #22d3ee;
    text-decoration: none;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.back-link:hover { text-decoration: underline; }

.session-detail-header {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.session-detail-header h2 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: #f1f5f9;
    font-size: 1.2rem;
}
.session-detail-header .session-meta {
    margin-bottom: 1rem;
}
.live-badge {
    color: #22c55e;
    font-weight: 600;
}
.session-id-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: #64748b;
}
.session-id-line code {
    background: #0f172a;
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
    color: #94a3b8;
    font-family: ui-monospace, monospace;
    font-size: 0.75rem;
}

/* Messages */
.messages h2 {
    margin-bottom: 1rem;
}
.message {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
}
.message.role-user { border-left: 3px solid #22d3ee; }
.message.role-assistant { border-left: 3px solid #fbbf24; }
.message.role-tool { border-left: 3px solid #a78bfa; background: #1a1f36; }
.message.role-system { border-left: 3px solid #64748b; opacity: 0.7; }
.message-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    margin-bottom: 0.5rem;
}
.message-role {
    color: #cbd5e1;
    font-weight: 500;
}
.message-time { color: #64748b; }
.message-content {
    color: #e2e8f0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.92rem;
}

.retry-btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: #fbbf24;
    color: #0f172a;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s;
}
.retry-btn:hover { background: #fcd34d; }

/* Schedule admin UI */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.section-header h2 { margin: 0; }
.btn-primary, .btn-primary-small {
    background: #fbbf24;
    color: #0f172a;
    padding: 0.6rem 1.25rem;
    border-radius: 0.4rem;
    text-decoration: none;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9rem;
}
.btn-primary-small { padding: 0.4rem 0.9rem; font-size: 0.85rem; }
.btn-primary:hover, .btn-primary-small:hover { background: #fcd34d; }

.btn-secondary {
    background: #334155;
    color: #e2e8f0;
    padding: 0.6rem 1.25rem;
    border-radius: 0.4rem;
    text-decoration: none;
    font-size: 0.9rem;
}
.btn-secondary:hover { background: #475569; }

.btn-delete {
    background: transparent;
    color: #f87171;
    border: 1px solid #ef4444;
    border-radius: 0.3rem;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-delete:hover {
    background: #dc2626;
    color: #fff;
}

/* Form styling */
.schedule-form {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    padding: 1.5rem;
}
.form-field {
    margin-bottom: 1.25rem;
}
.form-field label {
    display: block;
    color: #f1f5f9;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}
.form-field input,
.form-field textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    border-radius: 0.4rem;
    font-size: 0.95rem;
    font-family: inherit;
}
.form-field input:focus,
.form-field textarea:focus {
    outline: none;
    border-color: #fbbf24;
}
.form-field textarea { resize: vertical; }
.form-field small {
    display: block;
    margin-top: 0.4rem;
    color: #94a3b8;
    font-size: 0.78rem;
    line-height: 1.5;
}
.form-field small code {
    background: #0f172a;
    padding: 0.05rem 0.35rem;
    border-radius: 0.25rem;
    color: #22d3ee;
    font-size: 0.75rem;
}
.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Status boxes */
.success-box {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid #22c55e;
    color: #4ade80;
    padding: 0.75rem 1rem;
    border-radius: 0.4rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.error-box {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    color: #f87171;
    padding: 0.75rem 1rem;
    border-radius: 0.4rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}
.tab {
    padding: 0.75rem 1.25rem;
    color: #cbd5e1;
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}
.tab:hover { color: #fbbf24; border-bottom-color: #475569; }
.tab.active {
    color: #fbbf24;
    border-bottom-color: #fbbf24;
    font-weight: 600;
}
.count {
    background: #334155;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    color: #94a3b8;
}
.tab.active .count {
    background: #fbbf24;
    color: #0f172a;
}
.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}
.search-bar input[type="text"] {
    flex: 1;
    padding: 0.75rem 1rem;
    background: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
    border-radius: 0.5rem;
    font-size: 1rem;
}
.search-bar input[type="text"]:focus {
    outline: none;
    border-color: #fbbf24;
}
.search-bar button {
    padding: 0.75rem 1.5rem;
    background: #fbbf24;
    color: #0f172a;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
}
.search-bar button:hover { background: #fcd34d; }
.clear-btn {
    padding: 0.75rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
}
.clear-btn:hover { color: #e2e8f0; }

h2 {
    font-size: 1.1rem;
    color: #94a3b8;
    margin-bottom: 1rem;
    font-weight: 500;
}
.entry {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}
.entry:hover { border-color: #475569; }
.entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}
.entry-id {
    color: #fbbf24;
    font-weight: 600;
}
.entry-meta {
    color: #64748b;
}
.entry-content {
    color: #cbd5e1;
    white-space: pre-wrap;
    word-break: break-word;
}
.schedule-entry .schedule-meta {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}
.schedule-meta code {
    background: #0f172a;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    color: #22d3ee;
    font-size: 0.85rem;
}
.schedule-meta .tz {
    color: #94a3b8;
    font-size: 0.85rem;
}
.tag {
    background: #312e81;
    color: #c7d2fe;
    padding: 0.1rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    margin-right: 0.25rem;
}
.schedule-prompt {
    font-size: 0.9rem;
    color: #94a3b8;
    padding-left: 0.75rem;
    border-left: 2px solid #334155;
}
.empty {
    text-align: center;
    color: #64748b;
    padding: 3rem 1rem;
    background: #1e293b;
    border-radius: 0.5rem;
    border: 1px dashed #334155;
}
.error {
    color: #f87171;
    font-size: 0.85rem;
}
footer {
    margin-top: 3rem;
    padding: 2rem 0;
    text-align: center;
    color: #475569;
    font-size: 0.85rem;
    border-top: 1px solid #1e293b;
}
