/* Kế Toán Bot — Design System */
:root {
    --bg: #0a0f1a;
    --surface: #111827;
    --surface-2: #1f2937;
    --accent: #3b82f6;
    --accent-light: #60a5fa;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --income: #22c55e;
    --expense: #ef4444;
    --text: #f1f5f9;
    --text-muted: #6b7280;
    --border: rgba(255,255,255,0.08);
    --glass-bg: rgba(255,255,255,0.05);
    --glass-border: rgba(255,255,255,0.1);
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter Tight', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.hidden { display: none !important; }

/* Login */
.login-overlay {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
}
.login-card {
    text-align: center; padding: 3rem 2.5rem;
    background: var(--surface); border-radius: 20px;
    border: 1px solid var(--glass-border);
    width: 360px;
}
.login-icon { font-size: 3rem; color: var(--accent); margin-bottom: 1rem; }
.login-card h2 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.login-card p { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }
.login-card input {
    width: 100%; padding: 0.75rem 1rem; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text); font-size: 1rem; margin-bottom: 1rem;
    outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
    width: 100%; padding: 0.75rem; border-radius: 8px;
    background: var(--accent); color: white; border: none;
    font-size: 1rem; font-weight: 600; cursor: pointer;
    transition: background 0.2s;
}
.login-card button:hover { background: var(--accent-light); }
.login-error { color: var(--danger); margin-top: 0.5rem; font-size: 0.85rem; }

/* Header */
.header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--surface); border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 0.75rem; }
.header-left i { color: var(--accent); font-size: 1.3rem; }
.header-left h1 { font-size: 1.1rem; font-weight: 700; }
.header-tabs { display: flex; gap: 0.25rem; }
.tab-btn {
    padding: 0.5rem 1rem; border: none; border-radius: 8px;
    background: transparent; color: var(--text-muted);
    font-size: 0.85rem; cursor: pointer; transition: all 0.2s;
    font-family: inherit; font-weight: 500;
}
.tab-btn:hover { color: var(--text); background: var(--glass-bg); }
.tab-btn.active { color: var(--accent); background: rgba(59,130,246,0.15); }

/* Tab content */
.tab-content { display: none; flex: 1; overflow: hidden; }
.tab-content.active { display: flex; flex-direction: column; }

/* Chat */
.chat-messages {
    flex: 1; overflow-y: auto; padding: 1rem 1.5rem;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 3px; }

.welcome-msg {
    text-align: center; padding: 3rem 1rem;
    max-width: 480px; margin: 0 auto;
}
.welcome-icon { font-size: 3rem; color: var(--accent); margin-bottom: 1rem; }
.welcome-msg h3 { margin-bottom: 0.5rem; }
.welcome-msg p { color: var(--text-muted); margin-bottom: 1rem; }
.examples { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.example {
    padding: 0.5rem 0.75rem; border-radius: 8px;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    font-size: 0.85rem; color: var(--accent-light); cursor: pointer;
    transition: background 0.2s;
}
.example:hover { background: rgba(59,130,246,0.15); }

.msg { display: flex; gap: 0.75rem; margin-bottom: 1rem; max-width: 85%; }
.msg.user { margin-left: auto; flex-direction: row-reverse; }
.msg-avatar {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; flex-shrink: 0;
}
.msg.user .msg-avatar { background: var(--accent); }
.msg.bot .msg-avatar { background: var(--success); }
.msg-bubble {
    padding: 0.75rem 1rem; border-radius: 12px;
    line-height: 1.6; font-size: 0.9rem;
}
.msg.user .msg-bubble { background: var(--accent); color: white; }
.msg.bot .msg-bubble { background: var(--surface-2); }
.msg.bot .msg-bubble p { margin-bottom: 0.5rem; }
.msg.bot .msg-bubble p:last-child { margin-bottom: 0; }
.msg.bot .msg-bubble strong { color: var(--accent-light); }
.msg.bot .msg-bubble code { background: var(--bg); padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.85em; }

.chat-input-bar {
    display: flex; gap: 0.5rem; padding: 0.75rem 1.5rem;
    background: var(--surface); border-top: 1px solid var(--border);
    flex-shrink: 0;
}
#chat-input {
    flex: 1; padding: 0.75rem 1rem; border-radius: 10px;
    border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text); font-size: 0.95rem; outline: none;
    font-family: inherit;
}
#chat-input:focus { border-color: var(--accent); }
#send-btn {
    padding: 0.75rem 1.25rem; border-radius: 10px;
    background: var(--accent); color: white; border: none;
    font-size: 1rem; cursor: pointer; transition: background 0.2s;
}
#send-btn:hover { background: var(--accent-light); }
#send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Dashboard */
.dashboard { padding: 1.5rem; overflow-y: auto; flex: 1; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
    background: var(--surface); border-radius: var(--radius);
    padding: 1.25rem; border: 1px solid var(--border);
}
.stat-card .label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; }
.stat-card .change { font-size: 0.8rem; margin-top: 0.25rem; }
.stat-card .change.up { color: var(--success); }
.stat-card .change.down { color: var(--danger); }
.stat-card.income .value { color: var(--income); }
.stat-card.expense .value { color: var(--expense); }
.stat-card.profit .value { color: var(--accent-light); }

.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
.card {
    background: var(--surface); border-radius: var(--radius);
    padding: 1.25rem; border: 1px solid var(--border);
}
.card h3 { font-size: 0.95rem; margin-bottom: 1rem; color: var(--text-muted); }
.card h3 i { margin-right: 0.5rem; }
.chart-card { min-height: 300px; }

.cat-item { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.cat-item:last-child { border: none; }
.cat-name { font-size: 0.85rem; }
.cat-amount { font-weight: 600; font-size: 0.85rem; }
.cat-amount.expense { color: var(--expense); }
.cat-amount.income { color: var(--income); }

.deadline-item { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.deadline-item:last-child { border: none; }
.deadline-name { font-size: 0.85rem; font-weight: 600; }
.deadline-date { font-size: 0.8rem; color: var(--text-muted); }
.deadline-badge {
    display: inline-block; padding: 0.15rem 0.5rem; border-radius: 4px;
    font-size: 0.7rem; font-weight: 600; margin-left: 0.5rem;
}
.deadline-badge.overdue { background: rgba(239,68,68,0.2); color: var(--danger); }
.deadline-badge.today { background: rgba(245,158,11,0.2); color: var(--warning); }
.deadline-badge.urgent { background: rgba(245,158,11,0.15); color: var(--warning); }
.deadline-badge.upcoming { background: rgba(59,130,246,0.15); color: var(--accent-light); }

/* Transactions page */
.transactions-page { padding: 1.5rem; overflow-y: auto; flex: 1; }
.tx-filters {
    display: flex; gap: 0.5rem; margin-bottom: 1rem; align-items: center; flex-wrap: wrap;
}
.tx-filters select, .tx-filters input {
    padding: 0.5rem 0.75rem; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text); font-family: inherit; font-size: 0.85rem;
}
.tx-filters button {
    padding: 0.5rem 1rem; border-radius: 8px;
    background: var(--accent); color: white; border: none;
    font-size: 0.85rem; cursor: pointer; font-family: inherit; font-weight: 500;
}
.btn-export { background: var(--success) !important; }

.tx-list { display: flex; flex-direction: column; gap: 0.5rem; }
.tx-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.75rem 1rem; background: var(--surface); border-radius: 10px;
    border: 1px solid var(--border);
}
.tx-left { flex: 1; }
.tx-desc { font-size: 0.9rem; font-weight: 500; }
.tx-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }
.tx-amount { font-weight: 700; font-size: 1rem; }
.tx-amount.income { color: var(--income); }
.tx-amount.expense { color: var(--expense); }
.tx-actions { display: flex; gap: 0.5rem; margin-left: 1rem; }
.tx-actions button {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 0.85rem; padding: 0.25rem;
}
.tx-actions button:hover { color: var(--text); }
.tx-actions button.delete:hover { color: var(--danger); }

.tx-pagination { display: flex; justify-content: center; gap: 0.5rem; margin-top: 1rem; }
.tx-pagination button {
    padding: 0.4rem 0.8rem; border-radius: 6px;
    background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text); cursor: pointer; font-size: 0.85rem;
}
.tx-pagination button.active { background: var(--accent); border-color: var(--accent); }

/* Deadlines page */
.deadlines-page { padding: 1.5rem; overflow-y: auto; flex: 1; }
.deadlines-page h2 { font-size: 1.2rem; margin-bottom: 1.5rem; }
.deadlines-list { display: flex; flex-direction: column; gap: 0.75rem; }
.dl-card {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.25rem; background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border);
}
.dl-info { flex: 1; }
.dl-name { font-weight: 600; font-size: 0.95rem; }
.dl-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }
.dl-right { text-align: right; }
.dl-date { font-size: 0.85rem; font-weight: 500; }
.dl-days { font-size: 0.8rem; margin-top: 0.2rem; }

/* Tax quarter info */
.tax-quarter-info { margin-bottom: 1rem; }
.tq-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.75rem; }
.tq-card {
    background: var(--surface); border-radius: var(--radius);
    padding: 1rem 1.25rem; border: 1px solid var(--border);
}
.tq-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.3rem; }
.tq-value { font-size: 1.25rem; font-weight: 700; }
.tq-value.success { color: var(--success); }
.tq-value.warning { color: var(--warning); }
.tq-value.error { color: var(--danger); }
.tq-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }
.tq-sub.success { color: var(--success); }
.tq-sub.warning { color: var(--warning); }
.tq-sub.error { color: var(--danger); }

/* Tax obligations table */
.tax-obligations { margin-bottom: 1.5rem; }
.tax-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.tax-table th {
    text-align: left; padding: 0.6rem 0.75rem; color: var(--text-muted);
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}
.tax-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.ob-row.overdue { background: rgba(239,68,68,0.05); }
.ob-row.filed { background: rgba(34,197,94,0.05); }
.ob-label { font-weight: 600; }
.ob-deadline { color: var(--text-muted); }
.ob-detail { font-size: 0.8rem; color: var(--text-muted); }
.ob-badge {
    display: inline-block; padding: 0.15rem 0.5rem; border-radius: 4px;
    font-size: 0.7rem; font-weight: 600; white-space: nowrap;
}
.ob-badge.filed { background: rgba(34,197,94,0.2); color: var(--success); }
.ob-badge.overdue { background: rgba(239,68,68,0.2); color: var(--danger); }
.ob-badge.pending { background: rgba(59,130,246,0.15); color: var(--accent-light); }

/* Email scanner page */
.email-page { padding: 1.5rem; overflow-y: auto; flex: 1; }
.email-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem;
}
.email-header h2 { font-size: 1.2rem; }
.btn-scan {
    padding: 0.5rem 1.25rem; border-radius: 8px;
    background: var(--accent); color: white; border: none;
    font-size: 0.85rem; cursor: pointer; font-family: inherit; font-weight: 500;
    transition: background 0.2s;
}
.btn-scan:hover { background: var(--accent-light); }
.btn-scan:disabled { opacity: 0.5; cursor: not-allowed; }

.email-scan-status { margin-bottom: 1rem; }
.email-status {
    padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.85rem;
}
.email-status.success { background: rgba(34,197,94,0.15); color: var(--success); border: 1px solid rgba(34,197,94,0.3); }
.email-status.error { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.email-status.warning { background: rgba(245,158,11,0.15); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }

.email-list { display: flex; flex-direction: column; gap: 0.5rem; }
.email-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.75rem 1rem; background: var(--surface); border-radius: 10px;
    border: 1px solid var(--border);
}
.email-left { flex: 1; min-width: 0; }
.email-subject { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-status-col { margin-left: 1rem; flex-shrink: 0; }
.email-badge {
    display: inline-block; padding: 0.2rem 0.6rem; border-radius: 4px;
    font-size: 0.75rem; font-weight: 600;
}
.email-badge.success { background: rgba(34,197,94,0.2); color: var(--success); }
.email-badge.error { background: rgba(239,68,68,0.2); color: var(--danger); }
.email-badge.skipped { background: rgba(107,114,128,0.2); color: var(--text-muted); }

/* Typing indicator */
.typing { display: flex; gap: 4px; align-items: center; padding: 0.5rem 0; }
.typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-muted); animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,80%,100% { transform: translateY(0); } 40% { transform: translateY(-6px); } }

/* Responsive */
@media (max-width: 768px) {
    .header { flex-direction: column; gap: 0.5rem; padding: 0.5rem 1rem; }
    .header-tabs { width: 100%; overflow-x: auto; }
    .tab-btn { font-size: 0.8rem; padding: 0.4rem 0.75rem; white-space: nowrap; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .msg { max-width: 95%; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
}
