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

:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-hover: #263348;
    --border: #334155;
    --text: #e2e8f0;
    --text-dim: #94a3b8;
    --accent: #38bdf8;
    --accent-dim: #0ea5e9;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.login-card h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

.login-card p {
    color: var(--text-dim);
    margin-bottom: 2rem;
}

.google-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: #fff;
    color: #333;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: box-shadow 0.2s;
}

.google-btn:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 16px;
}

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

.logo {
    font-size: 1.1rem;
    color: var(--accent);
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-logout:hover {
    border-color: var(--text-dim);
    color: var(--text);
}

/* Search */
.search-bar {
    margin-bottom: 10px;
}

.search-bar input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
}

.search-bar input:focus {
    border-color: var(--accent);
}

.search-bar input::placeholder {
    color: var(--text-dim);
}

/* Categories */
.categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cat-btn {
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: none;
    color: var(--text-dim);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.cat-btn:hover {
    border-color: var(--text-dim);
    color: var(--text);
}

.cat-btn.active {
    border-color: transparent;
    color: #fff;
    font-weight: 500;
}

/* Stats */
.stats-bar {
    max-width: 1200px;
    margin: 12px auto;
    padding: 8px 16px;
    font-size: 0.85rem;
    color: var(--text-dim);
}

/* Email List */
.email-list {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px 24px;
}

.email-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.email-row:hover {
    border-color: var(--accent-dim);
}

.email-summary {
    display: grid;
    grid-template-columns: 120px 1fr 160px 60px;
    gap: 12px;
    padding: 10px 14px;
    align-items: center;
    font-size: 0.9rem;
    cursor: pointer;
}

.email-actions {
    text-align: right;
}

.btn-open {
    display: inline-block;
    padding: 3px 10px;
    font-size: 0.75rem;
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.15s;
}

.btn-open:hover {
    border-color: var(--accent);
    background: rgba(56,189,248,0.1);
}

.email-date {
    color: var(--text-dim);
    font-size: 0.8rem;
    white-space: nowrap;
}

.email-subject {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.email-from {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-dim);
    font-size: 0.85rem;
}

.email-mailbox {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-dim);
    font-size: 0.8rem;
    text-align: right;
}

.email-detail {
    display: none;
    padding: 0 14px 12px;
    border-top: 1px solid var(--border);
}

.email-detail.open {
    display: block;
}

.email-detail-row {
    margin-top: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.email-detail-label {
    color: var(--text-dim);
    font-weight: 500;
}

.email-detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.email-snippet {
    margin-top: 10px;
    padding: 10px;
    background: var(--bg);
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-dim);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Category Tag Colors */
.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.tag-dalia { background: rgba(56,189,248,0.2); color: #38bdf8; }
.tag-inga { background: rgba(167,139,250,0.2); color: #a78bfa; }
.tag-laima { background: rgba(74,222,128,0.2); color: #4ade80; }
.tag-hr { background: rgba(251,191,36,0.2); color: #fbbf24; }
.tag-other { background: rgba(251,146,60,0.2); color: #fb923c; }

/* Email body (plain text) */
.email-body {
    margin-top: 10px;
    padding: 12px;
    background: var(--bg);
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 600px;
    overflow-y: auto;
}

/* Email body (HTML iframe) */
.email-body-frame-wrap {
    margin-top: 10px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.email-body-frame {
    width: 100%;
    min-height: 200px;
    max-height: 800px;
    border: none;
    background: #fff;
    border-radius: 6px;
}

/* Attachments */
.email-attachments {
    margin-top: 10px;
    font-size: 0.85rem;
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-dim);
    font-size: 0.8rem;
}

.attachment-item svg {
    flex-shrink: 0;
    color: var(--accent);
}

.attachment-link {
    color: var(--accent);
    text-decoration: none;
}

.attachment-link:hover {
    text-decoration: underline;
}

.attachment-size {
    color: var(--text-dim);
    opacity: 0.7;
}

/* Indicators (body/attachment badges) */
.indicator {
    display: inline-block;
    font-size: 0.6rem;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 600;
    vertical-align: middle;
    margin-left: 4px;
}

.indicator-body {
    background: rgba(56,189,248,0.15);
    color: #38bdf8;
}

.indicator-attach {
    background: rgba(251,191,36,0.15);
    color: #fbbf24;
}

/* Search highlight */
mark {
    background: rgba(251,191,36,0.3);
    color: var(--text);
    border-radius: 2px;
    padding: 0 2px;
}

/* Load More */
.load-more-wrap {
    text-align: center;
    padding: 16px;
}

.btn-load-more {
    padding: 10px 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--accent);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-load-more:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
}

/* Loading spinner */
.spinner {
    text-align: center;
    padding: 40px;
    color: var(--text-dim);
}

/* Responsive */
@media (max-width: 768px) {
    .email-summary {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .email-date { order: 1; }
    .email-subject { order: 0; white-space: normal; }
    .email-from { order: 2; }
    .email-mailbox { order: 3; text-align: left; }

    .header-top { flex-direction: column; gap: 8px; align-items: flex-start; }
}
