/* ============================================
   Business Hub - Design System CSS
   Clean, Professional, ShadCN-inspired
   ============================================ */

:root {
    --background: #fafafa;
    --foreground: #0f172a;
    --card: #ffffff;
    --card-fg: #0f172a;
    --primary: #0f172a;
    --primary-fg: #f8fafc;
    --secondary: #f1f5f9;
    --secondary-fg: #0f172a;
    --muted: #f1f5f9;
    --muted-fg: #64748b;
    --accent: #f1f5f9;
    --border: #e2e8f0;
    --input: #e2e8f0;
    --ring: #0f172a;
    
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #3b82f6;
    --info-light: #dbeafe;
    --error: #ef4444;
    --error-light: #fee2e2;
    
    --business: #3b82f6;
    --business-light: #dbeafe;
    --personal: #64748b;
    --personal-light: #f1f5f9;
    --ignore: #f59e0b;
    --ignore-light: #fef3c7;
    --split: #8b5cf6;
    --split-light: #ede9fe;
    --pending: #94a3b8;
    --pending-light: #f8fafc;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', Consolas, monospace;
    --radius: 0.5rem;
    --radius-sm: 0.375rem;
    --radius-lg: 0.75rem;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px rgb(0 0 0 / 0.1), 0 1px 2px rgb(0 0 0 / 0.06);
    --shadow-md: 0 4px 6px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px rgb(0 0 0 / 0.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font-sans); background: var(--background); color: var(--foreground); line-height: 1.6; min-height: 100vh; }

/* Layout */
.app-container { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: 260px; background: var(--card); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; transition: transform 0.2s; }
.sidebar-header { padding: 1.25rem 1rem; border-bottom: 1px solid var(--border); }
.sidebar-logo { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: var(--foreground); }
.sidebar-logo-icon { width: 36px; height: 36px; background: linear-gradient(135deg, var(--primary), #334155); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--primary-fg); font-weight: 700; font-size: 0.875rem; }
.sidebar-logo-text { font-weight: 600; font-size: 1.0625rem; }
.sidebar-nav { flex: 1; padding: 1rem 0.75rem; overflow-y: auto; }
.nav-section { margin-bottom: 1.5rem; }
.nav-section-title { font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-fg); padding: 0 0.75rem; margin-bottom: 0.5rem; }
.nav-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.625rem 0.75rem; border-radius: var(--radius-sm); color: var(--muted-fg); text-decoration: none; font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: all 0.15s; border: none; background: none; width: 100%; text-align: left; }
.nav-item:hover { background: var(--muted); color: var(--foreground); }
.nav-item.active { background: var(--primary); color: var(--primary-fg); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--error); color: white; font-size: 0.625rem; font-weight: 700; padding: 0.125rem 0.5rem; border-radius: 9999px; min-width: 20px; text-align: center; }
.sidebar-footer { padding: 1rem; border-top: 1px solid var(--border); }

/* Main Content */
.main-content { flex: 1; margin-left: 260px; display: flex; flex-direction: column; min-height: 100vh; }
.main-header { height: 64px; background: var(--card); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; position: sticky; top: 0; z-index: 30; }
.page-title { font-size: 1.125rem; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 0.75rem; }
.global-selectors { display: flex; gap: 0.5rem; align-items: center; }
.global-selectors select { min-width: 140px; max-width: 200px; font-size: 0.8125rem; }
.main-body { flex: 1; padding: 1.5rem; max-width: 1600px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 1.5rem; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.card-title { font-size: 1rem; font-weight: 600; color: var(--foreground); }
.card-description { font-size: 0.8125rem; color: var(--muted-fg); margin-top: 0.25rem; }
.card-content { padding: 1.5rem; }
.card-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; }

/* Metrics */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.metric-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.metric-header { display: flex; align-items: flex-start; justify-content: space-between; }
.metric-label { font-size: 0.8125rem; font-weight: 500; color: var(--muted-fg); }
.metric-icon { width: 40px; height: 40px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; }
.metric-icon svg { width: 20px; height: 20px; }
.metric-icon.blue { background: var(--info-light); color: var(--info); }
.metric-icon.green { background: var(--success-light); color: var(--success); }
.metric-icon.amber { background: var(--warning-light); color: var(--warning); }
.metric-icon.red { background: var(--error-light); color: var(--error); }
.metric-icon.purple { background: var(--split-light); color: var(--split); }
.metric-value { font-size: 1.75rem; font-weight: 700; font-family: var(--font-mono); letter-spacing: -0.025em; line-height: 1.2; }
.metric-footer { font-size: 0.75rem; color: var(--muted-fg); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; font-family: var(--font-sans); font-size: 0.875rem; font-weight: 500; padding: 0.5rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; transition: all 0.15s; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover:not(:disabled) { background: #1e293b; }
.btn-secondary { background: var(--secondary); color: var(--secondary-fg); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--muted); }
.btn-ghost { background: transparent; color: var(--muted-fg); }
.btn-ghost:hover:not(:disabled) { background: var(--muted); color: var(--foreground); }
.btn-destructive { background: var(--error); color: white; }
.btn-destructive:hover:not(:disabled) { background: #dc2626; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.625rem 1.25rem; font-size: 0.9375rem; }
.btn-icon { padding: 0.5rem; }
.btn-icon.btn-sm { padding: 0.375rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.8125rem; font-weight: 500; color: var(--foreground); margin-bottom: 0.375rem; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 0.5rem 0.75rem; font-family: var(--font-sans); font-size: 0.875rem; border: 1px solid var(--input); border-radius: var(--radius-sm); background: var(--card); color: var(--foreground); transition: border-color 0.15s, box-shadow 0.15s; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08); }
.form-input::placeholder { color: var(--muted-fg); }
.form-input-sm { padding: 0.375rem 0.625rem; font-size: 0.8125rem; }
.form-textarea { min-height: 80px; resize: vertical; }
.form-checkbox { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.form-hint { font-size: 0.75rem; color: var(--muted-fg); margin-top: 0.25rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }

/* Tables */
.table-container { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--card); }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th { text-align: left; padding: 0.875rem 1rem; background: var(--muted); font-weight: 600; color: var(--foreground); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 0.875rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(241, 245, 249, 0.5); }
.table-mono { font-family: var(--font-mono); font-size: 0.8125rem; }
.table-amount { text-align: right; font-family: var(--font-mono); font-weight: 500; }
.table-amount.positive { color: var(--success); }
.table-amount.negative { color: var(--error); }
.table-actions { display: flex; gap: 0.25rem; justify-content: flex-end; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 0.125rem 0.5rem; font-size: 0.6875rem; font-weight: 600; border-radius: 9999px; text-transform: uppercase; letter-spacing: 0.025em; }
.badge-business { background: var(--business-light); color: var(--business); }
.badge-personal { background: var(--personal-light); color: var(--personal); }
.badge-ignore { background: var(--ignore-light); color: var(--ignore); }
.badge-split { background: var(--split-light); color: var(--split); }
.badge-pending { background: var(--pending-light); color: var(--pending); }
.badge-success, .badge-paid { background: var(--success-light); color: var(--success); }
.badge-warning, .badge-sent { background: var(--warning-light); color: var(--warning); }
.badge-error, .badge-overdue { background: var(--error-light); color: var(--error); }
.badge-info, .badge-draft { background: var(--info-light); color: var(--info); }

/* Modals */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s; }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 500px; max-height: calc(100vh - 2rem); overflow: hidden; display: flex; flex-direction: column; transform: scale(0.95); transition: transform 0.2s; }
.modal-overlay.active .modal { transform: scale(1); }
.modal-lg { max-width: 700px; }
.modal-xl { max-width: 900px; }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 1.125rem; font-weight: 600; }
.modal-close { background: none; border: none; padding: 0.375rem; cursor: pointer; color: var(--muted-fg); border-radius: var(--radius-sm); transition: all 0.15s; }
.modal-close:hover { background: var(--muted); color: var(--foreground); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; }

/* Toasts */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 60; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 0.75rem; min-width: 320px; max-width: 420px; animation: toastIn 0.3s ease; }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.removing { animation: toastOut 0.2s ease forwards; }
@keyframes toastOut { to { transform: translateX(100%); opacity: 0; } }
.toast-icon { flex-shrink: 0; }
.toast-icon svg { width: 20px; height: 20px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--error); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }
.toast-content { flex: 1; }
.toast-title { font-weight: 600; font-size: 0.875rem; }
.toast-message { font-size: 0.8125rem; color: var(--muted-fg); margin-top: 0.125rem; }
.toast-close { background: none; border: none; padding: 0.25rem; cursor: pointer; color: var(--muted-fg); opacity: 0.5; transition: opacity 0.15s; }
.toast-close:hover { opacity: 1; }

/* Tabs */
.tabs-list { display: flex; border-bottom: 1px solid var(--border); gap: 0; overflow-x: auto; margin-bottom: 1.5rem; }
.tab-trigger { padding: 0.75rem 1rem; font-size: 0.875rem; font-weight: 500; color: var(--muted-fg); background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; transition: all 0.15s; white-space: nowrap; margin-bottom: -1px; }
.tab-trigger:hover { color: var(--foreground); }
.tab-trigger.active { color: var(--foreground); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Section Headers */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.section-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; }
.section-description { color: var(--muted-fg); font-size: 0.875rem; margin-top: 0.25rem; }
.section-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Empty State */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--muted-fg); }
.empty-state-icon { width: 64px; height: 64px; margin: 0 auto 1.25rem; opacity: 0.4; }
.empty-state-icon svg { width: 100%; height: 100%; }
.empty-state-title { font-size: 1.125rem; font-weight: 600; color: var(--foreground); margin-bottom: 0.5rem; }
.empty-state-description { font-size: 0.875rem; margin-bottom: 1.5rem; max-width: 400px; margin-left: auto; margin-right: auto; }

/* Login Page */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%); }
.login-card { width: 100%; max-width: 400px; }
.login-header { text-align: center; margin-bottom: 2rem; }
.login-header h1 { font-size: 1.5rem; font-weight: 700; margin-top: 1rem; }
.login-logo { width: 64px; height: 64px; background: linear-gradient(135deg, var(--primary), #334155); border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; color: var(--primary-fg); font-weight: 700; font-size: 1.5rem; margin: 0 auto; box-shadow: var(--shadow-md); }

/* Calculator Display */
.calc-display { background: var(--muted); border-radius: var(--radius); padding: 1rem; margin-top: 1rem; }
.calc-row { display: flex; justify-content: space-between; padding: 0.375rem 0; font-size: 0.875rem; }
.calc-row.separator { border-top: 1px dashed var(--border); margin-top: 0.5rem; padding-top: 0.625rem; }
.calc-row.total { border-top: 2px solid var(--border); margin-top: 0.5rem; padding-top: 0.75rem; font-weight: 600; }
.calc-label { color: var(--muted-fg); }
.calc-value { font-family: var(--font-mono); font-weight: 500; }
.calc-value.highlight { color: var(--success); font-weight: 600; }

/* Account Groups */
.account-group { margin-bottom: 1.5rem; }
.account-header { display: flex; align-items: center; justify-content: space-between; padding: 0.875rem 1rem; background: var(--secondary); border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 0.5rem; transition: background 0.15s; }
.account-header:hover { background: #e8ecf1; }
.account-name { font-weight: 600; display: flex; align-items: center; gap: 0.5rem; font-size: 0.9375rem; }
.account-name svg { width: 16px; height: 16px; transition: transform 0.2s; }
.account-header.collapsed .account-name svg { transform: rotate(-90deg); }
.account-stats { display: flex; gap: 1.5rem; font-size: 0.8125rem; color: var(--muted-fg); }
.account-content { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.account-content.collapsed { display: none; }

/* Transaction Rows */
.tx-row { display: grid; grid-template-columns: 36px 90px 1fr 100px 90px 90px; gap: 0.75rem; align-items: center; padding: 0.75rem 1rem; font-size: 0.875rem; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.tx-row:hover { background: var(--muted); }
.tx-row:last-child { border-bottom: none; }
.tx-header { font-weight: 600; background: var(--muted); }
.tx-date { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--muted-fg); }
.tx-payee { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-memo { font-size: 0.75rem; color: var(--muted-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 0.125rem; }
.tx-amount { font-family: var(--font-mono); text-align: right; font-weight: 500; }
.tx-amount.income { color: var(--success); }
.tx-amount.expense { color: var(--error); }

/* Summary Boxes */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.summary-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; }
.summary-box-title { font-size: 0.8125rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-fg); margin-bottom: 1rem; }
.summary-item { display: flex; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.summary-item:last-child { border-bottom: none; }
.summary-item-label { color: var(--muted-fg); font-size: 0.875rem; }
.summary-item-value { font-family: var(--font-mono); font-weight: 600; }

/* Utilities */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.gap-6 { gap: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.ml-auto { margin-left: auto; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-muted { color: var(--muted-fg); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.cursor-pointer { cursor: pointer; }

/* Grid Layouts */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }

/* Responsive */
@media (max-width: 1200px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .tx-row { grid-template-columns: 36px 80px 1fr 90px; }
    .tx-row > :nth-child(5), .tx-row > :nth-child(6) { display: none; }
    .section-header { flex-direction: column; align-items: flex-start; }
    .modal { max-width: 100%; margin: 0.5rem; }
}

@media (max-width: 640px) {
    .metrics-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .main-body { padding: 1rem; }
}
