/* ============================================================
   Axion Office - UI styles
   ============================================================ */
:root {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --sidebar: #0f172a;
    --sidebar-hover: #1e293b;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --green: #16a34a;
    --red: #dc2626;
    --amber: #d97706;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: var(--sidebar);
    color: #cbd5e1;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 18px 0;
}
.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 20px 20px;
    font-weight: 700; font-size: 16px; color: #fff;
}
.brand-mark {
    display: inline-grid; place-items: center;
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--primary); color: #fff; font-weight: 800;
}
.brand-mark.lg { width: 48px; height: 48px; font-size: 22px; margin: 0 auto 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px;
    color: #cbd5e1; text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }
.ico { width: 18px; text-align: center; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 60px; background: var(--panel);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
}
.topbar-title { font-weight: 600; font-size: 15px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.bell { cursor: pointer; }
.user-chip { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.avatar { font-size: 18px; }
.logout { color: var(--muted); font-size: 13px; }

.content { padding: 24px; max-width: 1200px; width: 100%; }

/* ---------- Dashboard ---------- */
.greeting { margin: 0 0 20px; font-size: 22px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-grid.one { grid-template-columns: 1fr; max-width: 320px; }
.stat-card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}
.stat-card.income  { border-left-color: var(--green); }
.stat-card.expense { border-left-color: var(--red); }
.stat-card.balance { border-left-color: var(--primary); }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.dash-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) {
    .dash-columns { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr; }
    .sidebar { width: 64px; }
    .brand-name, .nav-link span:not(.ico) { display: none; }
}

/* ---------- Panels & tables ---------- */
.panel {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 20px; overflow: hidden;
}
.panel.pad { padding: 20px; }
.pad { padding: 20px; }
.panel-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.panel-head h3 { margin: 0; font-size: 15px; }
.panel h3 { margin-top: 0; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.text-right { text-align: right; }
.strong { font-weight: 600; }
.mono { font-family: "SF Mono", Consolas, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- Chart ---------- */
.chart { padding: 20px; }
.bars { display: flex; align-items: flex-end; gap: 16px; height: 180px; padding-bottom: 8px; }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-pair { flex: 1; display: flex; align-items: flex-end; gap: 4px; width: 100%; justify-content: center; }
.bar { width: 14px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-in { background: var(--green); }
.bar-out { background: var(--red); }
.bar-label { font-size: 11px; color: var(--muted); margin-top: 6px; }
.chart-legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin-top: 12px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; }
.dot-in { background: var(--green); } .dot-out { background: var(--red); }

/* ---------- Badges ---------- */
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 600; text-transform: capitalize;
    background: #e2e8f0; color: #475569;
}
.badge-paid { background: #dcfce7; color: #166534; }
.badge-sent { background: #dbeafe; color: #1e40af; }
.badge-overdue { background: #fee2e2; color: #991b1b; }
.badge-draft { background: #f1f5f9; color: #475569; }
.badge-cancelled { background: #f3f4f6; color: #6b7280; }
.badge-invoice { background: #dcfce7; color: #166534; }
.badge-expense { background: #fee2e2; color: #991b1b; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block; padding: 9px 16px; border-radius: 8px;
    border: 1px solid var(--border); background: #fff; color: var(--text);
    font-weight: 500; cursor: pointer; font-size: 14px; text-decoration: none;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fff; color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-block { width: 100%; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 4px 8px; }
.btn-icon:hover { color: var(--red); }

/* ---------- Forms ---------- */
.form label { display: block; margin-bottom: 14px; font-weight: 500; font-size: 13px; }
.form input, .form select, .form textarea {
    display: block; width: 100%; margin-top: 5px;
    padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; font-family: inherit; background: #fff;
}
.form input:focus, .form select:focus, .form textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.col-span-2 { grid-column: span 2; }
.form-actions { margin-top: 8px; }
.mt { margin-top: 18px; }

/* ---------- Page heads ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 20px; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.searchbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.searchbar input { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; }
.quick-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.link { color: var(--primary); font-size: 13px; }

/* ---------- Detail list ---------- */
.detail-list { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; }

/* ---------- Invoice ---------- */
.items-table input { margin: 0; }
.totals { margin-top: 18px; margin-left: auto; max-width: 300px; }
.totals > div { display: flex; justify-content: space-between; padding: 6px 0; }
.totals .grand { border-top: 2px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 16px; }
.invoice-parties { display: flex; justify-content: space-between; gap: 20px; }

/* ---------- Email (legacy simple table, still used elsewhere) ---------- */
.mail-table tr.unread { font-weight: 600; }
.mail-from { width: 220px; }
.mail-date { width: 140px; color: var(--muted); }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox-label input { width: auto; margin: 0; }

/* ---------- Email (Outlook-style three-pane) ---------- */
.mail-app {
    display: grid;
    grid-template-columns: 240px 340px 1fr;
    height: calc(100vh - 108px);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

/* Pane 1 — nav */
.mail-nav { border-right: 1px solid var(--border); display: flex; flex-direction: column; background: #fafbfc; }
.mail-nav-head { padding: 14px; }
.mail-accounts { padding: 0 8px 8px; border-bottom: 1px solid var(--border); }
.mail-account {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: 8px; color: var(--text); text-decoration: none;
}
.mail-account:hover { background: #eef2f7; text-decoration: none; }
.mail-account.active { background: #e0e7ff; }
.mail-account-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700;
}
.mail-account-meta { display: flex; flex-direction: column; min-width: 0; }
.mail-account-label { font-weight: 600; font-size: 13px; }
.mail-account-email { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-manage { display: block; padding: 8px 10px; font-size: 12px; color: var(--muted); }
.mail-folders { padding: 10px 8px; overflow-y: auto; flex: 1; }
.mail-folder {
    display: block; padding: 8px 10px; border-radius: 8px;
    color: var(--text); text-decoration: none; font-size: 13px;
}
.mail-folder:hover { background: #eef2f7; text-decoration: none; }
.mail-folder.active { background: var(--primary); color: #fff; }

/* Pane 2 — message list */
.mail-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.mail-list-head {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: baseline;
}
.mail-folder-title { font-weight: 700; text-transform: capitalize; }
.mail-items { overflow-y: auto; flex: 1; }
.mail-item {
    display: block; padding: 12px 16px; border-bottom: 1px solid var(--border);
    color: var(--text); text-decoration: none; border-left: 3px solid transparent;
}
.mail-item:hover { background: #f8fafc; text-decoration: none; }
.mail-item.selected { background: #eef2f7; border-left-color: var(--primary); }
.mail-item.unread { border-left-color: var(--primary); }
.mail-item.unread .mail-item-from,
.mail-item.unread .mail-item-subject { font-weight: 700; }
.mail-item-top { display: flex; justify-content: space-between; gap: 8px; }
.mail-item-from { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-item-date { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.mail-item-subject { font-size: 13px; color: #334155; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-pager { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); }

/* Pane 3 — reading pane */
.mail-read { display: flex; flex-direction: column; min-width: 0; }
.mail-read-head { padding: 18px 22px; border-bottom: 1px solid var(--border); }
.mail-read-subject { margin: 0 0 10px; font-size: 18px; }
.mail-read-meta { margin-bottom: 12px; }
.mail-read-actions { display: flex; gap: 8px; }
.mail-read-body { flex: 1; overflow: auto; padding: 0; }
.mail-frame { width: 100%; height: 100%; border: 0; }
.mail-plain { padding: 22px; white-space: pre-wrap; word-wrap: break-word; font-family: inherit; margin: 0; }
.mail-empty { flex: 1; display: grid; place-content: center; text-align: center; }
.mail-empty-icon { font-size: 48px; opacity: .4; }

/* Compose modal */
.mail-compose-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,.5);
    display: none; align-items: flex-end; justify-content: flex-end; z-index: 100;
}
.mail-compose-overlay.open { display: flex; }
.mail-compose {
    background: #fff; width: 560px; max-width: 100%; height: 560px; max-height: 90vh;
    margin: 0 24px 0 0; border-radius: 12px 12px 0 0; display: flex; flex-direction: column;
    box-shadow: 0 -8px 30px rgba(0,0,0,.25);
}
.mail-compose-head {
    background: var(--sidebar); color: #fff; padding: 12px 16px;
    display: flex; justify-content: space-between; align-items: center;
    border-radius: 12px 12px 0 0; font-weight: 600;
}
.mail-compose-head .btn-icon { color: #cbd5e1; }
.mail-compose-form { display: flex; flex-direction: column; flex: 1; padding: 14px; }
.mail-compose-field { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); padding: 8px 4px; }
.mail-compose-field label { width: 60px; color: var(--muted); font-size: 13px; margin: 0; }
.mail-compose-field input { border: none; flex: 1; padding: 4px; margin: 0; }
.mail-compose-field input:focus { outline: none; box-shadow: none; }
.mail-compose-form textarea { flex: 1; border: none; padding: 12px 4px; resize: none; font-family: inherit; margin-top: 8px; }
.mail-compose-form textarea:focus { outline: none; box-shadow: none; }
.mail-compose-actions { display: flex; gap: 10px; padding-top: 10px; border-top: 1px solid var(--border); }

@media (max-width: 1000px) {
    .mail-app { grid-template-columns: 1fr; height: auto; }
    .mail-nav, .mail-list { border-right: none; border-bottom: 1px solid var(--border); }
    .mail-frame { min-height: 400px; }
}

/* ---------- Calendar (legacy list, kept for compatibility) ---------- */
.event-list { padding: 8px; }
.event-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid var(--border); }
.event-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.event-body { flex: 1; }
.event-title { font-weight: 600; }
.event-time { color: var(--muted); font-size: 12px; }

/* ---------- Calendar (Teams-style) ---------- */
.cal-page { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.cal-main { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.cal-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 10px; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-title { margin: 0 0 0 8px; font-size: 18px; }
.cal-views { display: flex; gap: 8px; }
.cal-view-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.cal-grid-wrap { padding: 0; }
.cal-grid { display: grid; }
.cal-month { grid-template-columns: repeat(7, 1fr); }
.cal-dow { padding: 8px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); background: #fafbfc; }
.cal-cell { min-height: 104px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; position: relative; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.other { background: #fafbfc; }
.cal-cell.other .cal-cell-date { color: #cbd5e1; }
.cal-cell.today { background: #eff6ff; }
.cal-cell.today .cal-cell-date { background: var(--primary); color: #fff; }
.cal-cell-date { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: 12px; font-weight: 600; }
.cal-cell-events { margin-top: 4px; display: flex; flex-direction: column; gap: 3px; }
.cal-more { font-size: 11px; color: var(--muted); padding-left: 2px; }

.cal-chip {
    --chip: #2563eb;
    background: color-mix(in srgb, var(--chip) 15%, white);
    border-left: 3px solid var(--chip);
    color: #1e293b; font-size: 11px; padding: 2px 6px; border-radius: 4px;
    cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-chip:hover { background: color-mix(in srgb, var(--chip) 28%, white); }
.cal-chip.invite { border-left-style: dashed; }
.chip-time { font-weight: 600; opacity: .8; }

.cal-week { grid-template-columns: repeat(7, 1fr); min-height: 420px; }
.cal-week-col { border-right: 1px solid var(--border); }
.cal-week-col:last-child { border-right: none; }
.cal-week-col.today { background: #eff6ff; }
.cal-week-head { padding: 8px; text-align: center; border-bottom: 1px solid var(--border); background: #fafbfc; display: flex; flex-direction: column; }
.cal-week-head span { font-size: 11px; color: var(--muted); }
.cal-week-events { padding: 6px; display: flex; flex-direction: column; gap: 4px; }

/* Invites sidebar */
.cal-side { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.cal-side-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cal-side-head h3 { margin: 0; font-size: 15px; }
.invite-card { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.invite-title { font-weight: 700; margin-bottom: 6px; }
.invite-meta { font-size: 13px; display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; }
.invite-note { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; margin-bottom: 8px; }
.invite-btns { display: flex; gap: 6px; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* Popover + modal */
.cal-pop-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.4); display: none; align-items: center; justify-content: center; z-index: 100; }
.cal-pop-overlay.open { display: flex; }
.cal-pop, .cal-modal { background: #fff; width: 420px; max-width: 92vw; border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.3); overflow: hidden; }
.pop-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-left: 5px solid var(--primary); }
.pop-head h3 { margin: 0; font-size: 16px; }
.pop-body { padding: 0 18px 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.pop-desc { color: var(--muted); white-space: pre-wrap; }
.pop-invite { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 6px; display: flex; flex-direction: column; gap: 8px; }
.pop-actions { margin-top: 8px; display: flex; gap: 8px; align-items: center; }

/* Attendee responses list */
.pop-attendees { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 6px; }
.att-head { font-weight: 700; font-size: 13px; display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.att-summary { font-weight: 400; font-size: 12px; color: var(--muted); }
.att-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13px; }
.att-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-status { font-weight: 600; font-size: 12px; flex-shrink: 0; margin-left: 10px; }
.att-accepted { color: var(--green); }
.att-declined { color: var(--red); }
.att-tentative { color: var(--amber); }
.att-needs-action { color: var(--muted); }
.att-note { font-size: 12px; color: var(--muted); font-style: italic; padding: 0 0 6px 18px; }
.cal-modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--sidebar); color: #fff; font-weight: 600; }
.cal-modal-head .btn-icon { color: #cbd5e1; }

@media (max-width: 1000px) {
    .cal-page { grid-template-columns: 1fr; }
    .cal-cell { min-height: 72px; }
}

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ---------- Auth ---------- */
body.centered { display: grid; place-items: center; min-height: 100vh; background: var(--sidebar); }
.auth-card {
    background: #fff; border-radius: 14px; padding: 34px;
    width: 360px; box-shadow: 0 20px 40px rgba(0,0,0,.3); text-align: center;
}
.auth-card .form { text-align: left; margin-top: 20px; }
.auth-brand h1 { margin: 6px 0 2px; font-size: 22px; }
.auth-card h1 { font-size: 22px; }

/* ---------- Print ---------- */
@media print {
    .sidebar, .topbar, .head-actions, .quick-actions { display: none !important; }
    .content { padding: 0; }
    .panel { box-shadow: none; border: none; }
}
