/* Allan Desk 2.0 — Modern Dark Control Center */
:root {
    --bg: #090a0c;
    --surface: #121417;
    --surface-elevated: #181b20;
    --surface-subtle: #0d0f12;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.18);
    --border-focus: #a3e635;
    --text: #f4f5f7;
    --muted: #8e94a0;
    --subtle: #585d68;
    --accent: #a3e635;
    --accent-glow: rgba(163, 230, 53, 0.16);
    --accent-dark: #1b260b;
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.08);
    --danger-border: rgba(248, 113, 113, 0.25);
    --ok: #4ade80;
    --ok-bg: rgba(74, 222, 128, 0.08);
    --ok-border: rgba(74, 222, 128, 0.25);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    --transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; transition: var(--transition); }
h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
h2 { margin: 0 0 16px; font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); }
p { margin: 0 0 12px; }

/* Layout Wrap */
.wrap {
    max-width: 1140px;
    margin: 0 auto;
    padding: 24px 24px 80px;
}

/* Glass Header & Navbar */
.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
    padding: 10px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.top-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.top-divider {
    width: 1px;
    height: 16px;
    background: var(--border);
}

.user-greeting-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 11px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    transition: var(--transition);
}
.user-greeting-badge:hover {
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.06);
}
.user-greeting-badge .greeting-icon {
    font-size: 13px;
    line-height: 1;
}
.user-greeting-badge .greeting-label {
    color: var(--muted);
    font-weight: 400;
}
.user-greeting-badge .greeting-user {
    color: var(--text);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.top-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

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

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: var(--transition);
}
.user-pill:hover {
    color: var(--text);
    background: var(--surface-subtle);
}
.user-avatar-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
    display: inline-block;
}

.brand {
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.brand-logo {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: contain;
    flex-shrink: 0;
    vertical-align: middle;
}
.brand span { color: var(--accent); }
.brand .badge-admin {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--accent-glow);
    color: var(--accent);
    padding: 2px 7px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(163, 230, 53, 0.3);
}

.nav {
    display: flex;
    gap: 4px;
    background: var(--surface-subtle);
    padding: 4px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* Button & Nav Tab Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: var(--accent);
    color: #0b0e07;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}
.btn:hover {
    background: #bbf758;
    border-color: #bbf758;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-glow);
}
.btn:active { transform: translateY(0); }

.btn.ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid transparent;
    font-weight: 500;
}
.btn.ghost:hover {
    background: var(--surface-elevated);
    color: var(--text);
    border-color: var(--border);
}
.btn.ghost.active, .nav a.btn.ghost {
    background: var(--surface-elevated);
    color: var(--text);
    border-color: var(--border);
}
.nav a.btn.plain {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
    font-weight: 500;
}
.nav a.btn.plain:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.btn.danger {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger-border);
    font-weight: 500;
}
.btn.danger:hover {
    background: rgba(248, 113, 113, 0.16);
    border-color: var(--danger);
}

.btn.plain {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
    font-weight: 500;
}
.btn.plain:hover { color: var(--text); }
.btn.btn-logout:hover { color: var(--danger); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: none; }

/* KPI Stats Cards */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stats > div {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition);
}
.stats > div:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
}
.stats b {
    display: block;
    font-size: 30px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}
.stats > div:first-child b { color: var(--accent); }
.stats span, .stats div { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }

/* Panels & Cards */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}
.panel.flush { padding: 0; overflow: hidden; }

/* Chart Bars */
.bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 56px;
    padding-top: 8px;
}
.bar {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    min-height: 4px;
    transition: var(--transition);
}
.bar.has {
    background: var(--accent);
    opacity: 0.85;
    box-shadow: 0 0 8px var(--accent-glow);
}
.bar.has:hover { opacity: 1; transform: scaleY(1.05); }
.bar-days {
    display: flex;
    gap: 6px;
    color: var(--subtle);
    font-size: 11px;
    margin-top: 8px;
}
.bar-days span { flex: 1; text-align: center; }

/* Message List & Filters */
.filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-subtle);
}
.filters a {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
}
.filters a:hover {
    background: var(--surface-elevated);
    color: var(--text);
    border-color: var(--border);
}
.filters a.on {
    background: var(--accent-dark);
    color: var(--accent);
    border-color: rgba(163, 230, 53, 0.35);
    font-weight: 600;
}
.filters .search { margin-left: auto; display: flex; gap: 8px; }
.filters .search input { width: 220px; padding: 7px 12px; font-size: 13px; }

/* Bulk Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}
.toolbar .pick-all { width: 28px; display: flex; align-items: center; }
.toolbar .spacer { flex: 1; }

/* Items / List Rows */
.item {
    display: grid;
    grid-template-columns: 28px 190px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--surface-elevated); }
.item .who, .item .snip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .who { font-weight: 500; color: var(--text); }
.item .snip { color: var(--muted); font-size: 13px; }
.item .when { color: var(--subtle); font-size: 12px; white-space: nowrap; }

.item.unread { background: rgba(163, 230, 53, 0.02); }
.item.unread .who {
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
}
.item.unread .who::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    margin-right: 10px;
    box-shadow: 0 0 6px var(--accent);
    flex-shrink: 0;
}
.item.unread .snip { color: var(--text); font-weight: 500; }
.empty { padding: 48px 18px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 12px; justify-content: center; align-items: center; padding: 18px; color: var(--muted); font-size: 13px; }

/* Conversation Thread */
.back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 16px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface-subtle);
    border: 1px solid var(--border);
}
.back:hover { color: var(--text); border-color: var(--border-hover); }
.convo-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.thread { display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; }
.bubble {
    max-width: 82%;
    padding: 16px 18px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface-subtle);
    box-shadow: var(--shadow-sm);
}
.bubble.out {
    align-self: flex-end;
    background: var(--accent-dark);
    border-color: rgba(163, 230, 53, 0.35);
}
.bubble .by { color: var(--muted); font-size: 12px; margin-bottom: 6px; font-weight: 500; }
.bubble.out .by { color: var(--accent); }
.bubble .text { white-space: pre-wrap; word-break: break-word; line-height: 1.6; }

/* Form Fields */
label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 16px 0 6px;
}
input[type=text],
input[type=password],
input[type=number],
input[type=email],
input[type=url],
textarea,
select {
    width: 100%;
    background: var(--surface-subtle);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font: inherit;
    font-size: 14px;
    transition: var(--transition);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface-elevated);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder, textarea::placeholder { color: var(--subtle); }

.hint { color: var(--subtle); font-size: 12px; margin-top: 6px; }

/* Checkboxes */
input[type=checkbox] {
    accent-color: var(--accent);
    width: 17px;
    height: 17px;
    margin: 0;
    cursor: pointer;
}

/* Flash notifications */
.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 14px;
    font-weight: 500;
    animation: fadeIn 0.25s ease-out;
}
.flash.success {
    background: var(--ok-bg);
    border-color: var(--ok-border);
    color: var(--ok);
}
.flash.error {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger);
}

/* Tag Pills */
.tag {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    color: var(--muted);
    background: var(--surface-subtle);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tag.ok { color: var(--ok); border-color: var(--ok-border); background: var(--ok-bg); }
.tag.bad { color: var(--danger); border-color: var(--danger-border); background: var(--danger-bg); }
.tag.featured { color: var(--accent); border-color: rgba(163, 230, 53, 0.4); background: var(--accent-glow); }

/* Live Hero Stats Preview Box */
.hero-stats-preview {
    background: #090909;
    border: 1px solid rgba(163, 230, 53, 0.3);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin: 20px 0;
    box-shadow: 0 0 25px rgba(163, 230, 53, 0.08);
}
.hero-stats-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 16px;
}
.hero-stat-card {
    border-left: 2px solid var(--accent);
    padding-left: 12px;
}
.hero-stat-card .num {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 32px;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 4px;
}
.hero-stat-card .lbl {
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
    line-height: 1.3;
    text-transform: uppercase;
}

/* Upload Progress Pill */
.upload-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--accent);
    margin-top: 6px;
    font-weight: 600;
}

/* Login Card */
.login {
    max-width: 400px;
    margin: 12vh auto 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
}

/* ==========================================================================
   Email Client View (Allan Desk Inbox)
   ========================================================================== */
.inbox-shell {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    min-height: 480px;
}

.inbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-subtle);
    flex-wrap: wrap;
}

.inbox-tabs {
    display: flex;
    gap: 6px;
}

.inbox-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}
.inbox-tab:hover {
    background: var(--surface-elevated);
    color: var(--text);
}
.inbox-tab.active {
    background: var(--accent-dark);
    color: var(--accent);
    font-weight: 600;
}

.count-pill {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
    font-weight: 600;
}
.count-pill.unread {
    background: var(--accent);
    color: #0b0e07;
    box-shadow: 0 0 8px var(--accent-glow);
}

.inbox-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 320px;
    margin-left: auto;
}
.inbox-search input {
    padding: 7px 12px;
    font-size: 13px;
}

.inbox-toolbar {
    background: rgba(0, 0, 0, 0.25);
    padding: 8px 18px;
}

.inbox-list {
    display: flex;
    flex-direction: column;
}

.inbox-row {
    display: grid;
    grid-template-columns: 28px 32px 160px minmax(0, 1fr) 80px 70px;
    gap: 12px;
    align-items: center;
    padding: 8px 16px;
    height: 48px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    box-sizing: border-box;
}
.inbox-row:last-child { border-bottom: 0; }
.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    line-height: 1.2;
}
.inbox-row:hover {
    background: var(--surface-elevated);
}

.inbox-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: var(--muted);
    flex-shrink: 0;
}
.inbox-row.unread .inbox-avatar {
    background: var(--accent-dark);
    border-color: rgba(163, 230, 53, 0.4);
    color: var(--accent);
}

.inbox-sender {
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    text-decoration: none;
}
.inbox-body {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
}
.inbox-snippet {
    display: inline-block;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.inbox-row.unread {
    background: rgba(163, 230, 53, 0.05);
    border-left: 3px solid var(--accent);
}
.inbox-row.unread:hover {
    background: rgba(163, 230, 53, 0.09);
}
.inbox-row.unread .inbox-sender {
    font-weight: 800;
    color: #ffffff;
    font-size: 13.5px;
    letter-spacing: -0.01em;
}
.inbox-row.unread .inbox-body {
    color: #ffffff;
    font-weight: 700;
}
.inbox-row.unread .inbox-snippet {
    color: #ffffff;
    font-weight: 600;
}
.inbox-row.read {
    border-left: 3px solid transparent;
    opacity: 0.85;
}
.inbox-row.read .inbox-sender {
    color: var(--muted);
    font-weight: 400;
}
.inbox-row.read .inbox-body {
    color: var(--muted);
    font-weight: 400;
}
.inbox-row.read .inbox-snippet {
    color: var(--subtle);
    font-weight: 400;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.sync-icon {
    display: inline-block;
}
.sync-btn.is-syncing .sync-icon {
    animation: spin 0.8s linear infinite;
}
.unread-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    margin-right: 6px;
    box-shadow: 0 0 8px var(--accent);
}
.badge-tag.unread-tag {
    background: var(--accent);
    color: #080a06;
    font-weight: 700;
}
.inbox-snippet {
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-tag {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}
.badge-tag.replied {
    background: var(--ok-bg);
    color: var(--ok);
    border: 1px solid var(--ok-border);
}
.badge-tag.incoming {
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid rgba(163, 230, 53, 0.3);
}

.inbox-time {
    color: var(--subtle);
    font-size: 12px;
    text-align: right;
    white-space: nowrap;
}
.inbox-row.unread .inbox-time {
    color: var(--accent);
    font-weight: 600;
}

.inbox-empty {
    padding: 64px 20px;
    text-align: center;
}
.empty-icon {
    font-size: 40px;
    color: var(--subtle);
    margin-bottom: 8px;
}
.empty-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}
.empty-sub {
    font-size: 13px;
    color: var(--muted);
}

/* Collapsible Analytics Drawer */
.analytics-drawer {
    margin-top: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-subtle);
    overflow: hidden;
}
.analytics-drawer summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    user-select: none;
    transition: var(--transition);
}
.analytics-drawer summary:hover {
    color: var(--text);
    background: var(--surface);
}
.drawer-hint {
    font-size: 12px;
    color: var(--subtle);
    font-weight: 400;
}
.analytics-content {
    padding: 18px;
    border-top: 1px solid var(--border);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .wrap { padding: 16px 14px 60px; }
    .top { flex-direction: column; align-items: stretch; gap: 12px; }
    .nav { overflow-x: auto; scrollbar-width: none; }
    .inbox-row { grid-template-columns: 24px 28px 1fr auto; gap: 10px; }
    .inbox-body { grid-column: 3 / 5; }
    .inbox-search { margin-left: 0; max-width: 100%; width: 100%; }
}
