/* ── Variables ──────────────────────────────────────────────── */
:root {
    --teal:        #1D9E75;
    --teal-light:  #E1F5EE;
    --teal-dark:   #0F6E56;
    --blue:        #185FA5;
    --blue-light:  #E6F1FB;
    --amber:       #EF9F27;
    --amber-light: #FAEEDA;
    --coral:       #D85A30;
    --coral-light: #FAECE7;
    --text-primary:   #1A1A1A;
    --text-secondary: #666666;
    --text-muted:     #999999;
    --bg-primary:     #FFFFFF;
    --bg-secondary:   #F7F7F5;
    --border:         rgba(0,0,0,0.08);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }

/* ── Layout Grid ───────────────────────────────────────────── */
.layout {
    display: grid;
    grid-template-columns: 220px 1fr 260px;
    grid-template-rows: 56px 1fr;
    grid-template-areas:
        "topbar topbar topbar"
        "sidebar main right";
    min-height: 100vh;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
    grid-area: topbar;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar__left { display: flex; align-items: center; gap: 12px; }
.topbar__menu-btn { display: none; padding: 4px; }
.topbar__logo { font-weight: 600; font-size: 15px; color: var(--teal); }
.topbar__pills { display: flex; gap: 8px; }
.topbar__right { display: flex; align-items: center; gap: 16px; }
.topbar__date { font-size: 13px; color: var(--text-secondary); }
.topbar__logout { color: var(--text-muted); transition: color 0.2s; }
.topbar__logout:hover { color: var(--coral); }

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.pill--coral { background: var(--coral-light); color: var(--coral); }
.pill--amber { background: var(--amber-light); color: var(--amber); }
.pill--blue  { background: var(--blue-light); color: var(--blue); }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    grid-area: sidebar;
    padding: 16px 12px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sidebar__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.sidebar__link:hover { background: var(--bg-secondary); color: var(--text-primary); }
.sidebar__link.active { background: var(--teal-light); color: var(--teal-dark); font-weight: 500; }
.sidebar__badge {
    margin-left: auto;
    background: var(--coral);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ── Main ──────────────────────────────────────────────────── */
.main {
    grid-area: main;
    padding: 24px;
    overflow-y: auto;
}

/* ── Right panel ───────────────────────────────────────────── */
.right-panel {
    grid-area: right;
    padding: 16px;
    background: var(--bg-primary);
    border-left: 1px solid var(--border);
    overflow-y: auto;
}

/* ── Bottom nav (mobile) ───────────────────────────────────── */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    justify-content: space-around;
    align-items: center;
    z-index: 100;
}
.bottom-nav a {
    color: var(--text-muted);
    padding: 8px;
}
.bottom-nav a.active { color: var(--teal); }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
}
.card__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* ── Digest card ───────────────────────────────────────────── */
.digest-card {
    background: var(--teal-light);
    border-color: transparent;
}
.digest-card .card__title { color: var(--teal-dark); }
.digest-card__content { font-size: 14px; line-height: 1.7; }
.digest-card__time { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ── Task list ─────────────────────────────────────────────── */
.task-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.task-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
}
.task-item__checkbox {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
    margin-top: 1px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}
.task-item__checkbox:checked {
    background: var(--teal);
    border-color: var(--teal);
}
.task-item__content { flex: 1; min-width: 0; }
.task-item__name { font-size: 14px; }
.task-item__meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.task-item__project {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
}
.task-item__deadline { font-size: 12px; font-weight: 500; }
.deadline--today { color: var(--coral); }
.deadline--tomorrow { color: var(--amber); }
.deadline--later { color: var(--text-muted); }

/* ── Email list ────────────────────────────────────────────── */
.email-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.email-item:last-child { border-bottom: none; }
.email-item__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}
.email-item__content { flex: 1; min-width: 0; }
.email-item__from { font-size: 13px; font-weight: 500; }
.email-item__subject { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-item__tag {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
}

/* ── Calendar timeline ─────────────────────────────────────── */
.calendar-event {
    padding: 8px 12px;
    border-left: 3px solid var(--teal);
    margin-bottom: 8px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--bg-secondary);
}
.calendar-event__time { font-size: 12px; font-weight: 500; color: var(--teal); }
.calendar-event__title { font-size: 13px; margin-top: 2px; }

/* ── Bot input ─────────────────────────────────────────────── */
.bot-input {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.bot-input__title { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.bot-input__form { display: flex; gap: 8px; }
.bot-input__field {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
.bot-input__field:focus { border-color: var(--teal); }
.bot-input__send {
    padding: 8px 14px;
    background: var(--teal);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}
.bot-input__send:hover { background: var(--teal-dark); }
.bot-input__reply {
    margin-top: 10px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: none;
}

/* ── Client cards ──────────────────────────────────────────── */
.client-card {
    border-left: 4px solid var(--teal);
}
.client-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}
.client-card__name { font-size: 16px; font-weight: 600; }
.client-card__folders { margin-top: 12px; }
.folder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.folder-item:last-child { border-bottom: none; }
.folder-item__icon { width: 20px; color: var(--text-muted); }
.folder-item__label { flex: 1; font-size: 13px; }
.folder-item__type {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--bg-secondary);
    color: var(--text-muted);
}

/* ── Inbox items ───────────────────────────────────────────── */
.inbox-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: var(--bg-primary);
}
.inbox-item__info { flex: 1; }
.inbox-item__filename { font-weight: 500; }
.inbox-item__suggestion { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.inbox-item__actions { display: flex; gap: 6px; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn--primary { background: var(--teal); color: #fff; }
.btn--primary:hover { background: var(--teal-dark); }
.btn--secondary { background: var(--bg-secondary); color: var(--text-secondary); }
.btn--secondary:hover { background: #eee; }
.btn--danger { background: var(--coral-light); color: var(--coral); }
.btn--danger:hover { background: #f5d5cc; }
.btn--sm { padding: 4px 10px; font-size: 12px; }

/* ── Auth pages ────────────────────────────────────────────── */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-secondary);
}
.auth-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 380px;
}
.auth-card__logo {
    text-align: center;
    margin-bottom: 32px;
}
.auth-card__logo h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--teal);
}
.auth-card__logo p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--teal); }
.form-error {
    color: var(--coral);
    font-size: 13px;
    margin-top: 4px;
}
.auth-submit {
    width: 100%;
    padding: 12px;
    background: var(--teal);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.auth-submit:hover { background: var(--teal-dark); }

/* ── Recovery codes ────────────────────────────────────────── */
.recovery-codes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin: 16px 0;
}
.recovery-codes__code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 14px;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    text-align: center;
    letter-spacing: 1px;
}

/* ── QR Code ───────────────────────────────────────────────── */
.qr-container {
    text-align: center;
    margin: 20px 0;
}
.qr-container svg { max-width: 220px; height: auto; }

/* ── Alert ─────────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}
.alert--error { background: var(--coral-light); color: var(--coral); }
.alert--success { background: var(--teal-light); color: var(--teal-dark); }
.alert--warning { background: var(--amber-light); color: #8a6200; }

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state__icon { font-size: 32px; margin-bottom: 8px; }
.empty-state__text { font-size: 14px; }

/* ── Log table ─────────────────────────────────────────────── */
.log-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.log-item__channel {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
    text-transform: uppercase;
}
.log-item__intent { color: var(--text-secondary); }
.log-item__time { color: var(--text-muted); font-size: 12px; margin-left: auto; }

/* ── Responsive: Tablet ────────────────────────────────────── */
@media (max-width: 1199px) {
    .layout {
        grid-template-columns: 1fr 260px;
        grid-template-areas:
            "topbar topbar"
            "main right";
    }
    .sidebar { display: none; }
    .topbar__menu-btn { display: block; }
    .sidebar.open {
        display: flex;
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        width: 220px;
        z-index: 99;
        box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    }
}

/* ── Responsive: Mobile ────────────────────────────────────── */
@media (max-width: 767px) {
    .layout {
        grid-template-columns: 1fr;
        grid-template-rows: 56px 1fr;
        grid-template-areas:
            "topbar"
            "main";
    }
    .sidebar { display: none; }
    .right-panel {
        display: none;
        grid-area: unset;
    }
    .main { padding: 16px; padding-bottom: 72px; }
    .bottom-nav { display: flex; }
    .topbar__pills { display: none; }
    .topbar__date { display: none; }
    .topbar__menu-btn { display: none; }
    .task-grid { grid-template-columns: 1fr; }

    .right-panel--mobile-visible {
        display: block;
        border-left: none;
        border-top: 1px solid var(--border);
    }
}
