/* goldenbooks-web/assets/css/style.css */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --sidebar: #1b2a4a;
  --sidebar-hover: #273c66;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --border: #dce1eb;
  --text: #1e293b;
  --muted: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); font-size: 13px; line-height: 1.45; }

.hidden { display: none !important; }
.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: 240px; background: var(--sidebar); color: #e2e8f0; display: flex; flex-direction: column; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.brand-logo { width: 34px; height: 34px; background: var(--success); color: #fff; font-weight: 700; border-radius: 6px; display: grid; place-items: center; font-size: 15px; flex-shrink: 0; }
.brand-title { font-weight: 700; font-size: 14px; color: #fff; }
.brand-sub { font-size: 11px; color: #94a3b8; }

.nav-menu { padding: 10px 8px; overflow-y: auto; flex: 1; }
.nav-group { font-size: 11px; text-transform: uppercase; color: #94a3b8; padding: 10px 10px 4px; letter-spacing: 0.5px; }
.nav-item { width: 100%; text-align: left; background: transparent; border: none; color: #cbd5e1; padding: 8px 10px; border-radius: 5px; cursor: pointer; font-size: 13px; margin-bottom: 2px; transition: 0.15s; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }

/* Main & Topbar */
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { min-height: 54px; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 20px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.topbar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar-left h1 { font-size: 17px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; background: #e0e7ff; color: #3730a3; padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.user-pill { background: #f1f5f9; padding: 5px 10px; border-radius: 14px; font-weight: 600; font-size: 12px; border: 1px solid var(--border); }
.dot-online { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--success); margin-left: 4px; }

/* Workspace & Cards */
.view-container { padding: 18px 20px; flex: 1; overflow-y: auto; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; margin-bottom: 16px; }
.grid-2 .card, .grid-3 .card { margin-bottom: 0; }
.card-header { padding: 11px 14px; background: #f8fafc; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-body { padding: 14px; flex: 1; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 8px; flex-wrap: wrap; }
.tab-btn { padding: 7px 12px; border: 1px solid var(--border); background: #fff; border-radius: 5px; cursor: pointer; font-size: 12.5px; font-weight: 500; color: var(--text); }
.tab-btn:hover { background: #f8fafc; }
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

/* Tables & Forms */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th, .table td { padding: 7px 8px; border-bottom: 1px solid #eef2f7; text-align: left; vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; background: #fafbfd; white-space: nowrap; }
.table tbody tr:hover { background: #f8fafc; }
.table tr.clickable { cursor: pointer; }
.table tr.row-total td { font-weight: 700; background: #f8fafc; border-top: 2px solid var(--border); }
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

.btn { padding: 7px 12px; border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 5px; cursor: pointer; font-size: 12.5px; font-weight: 500; transition: 0.15s; }
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.form-control { width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 5px; font-size: 13px; background: #fff; color: var(--text); }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15); }
.form-row { display: flex; gap: 10px; margin-bottom: 10px; align-items: center; }
.form-group { margin-bottom: 10px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }

/* Trend Bar Chart (Ch 1 Snapshot) */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 170px; padding-top: 15px; border-bottom: 1px solid var(--border); }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bar-pair { display: flex; gap: 3px; align-items: flex-end; height: 140px; width: 100%; justify-content: center; }
.bar-inc { width: 10px; background: #60a5fa; border-radius: 2px 2px 0 0; min-height: 2px; transition: height 0.2s; }
.bar-exp { width: 10px; background: #1e3a8a; border-radius: 2px 2px 0 0; min-height: 2px; transition: height 0.2s; }
.bar-label { font-size: 10px; color: var(--muted); margin-top: 5px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,0.45); display: flex; align-items: center; justify-content: center; z-index: 999; padding: 16px; }
.modal-box { background: #fff; width: 540px; max-width: 96vw; border-radius: 8px; overflow: hidden; box-shadow: 0 20px 40px rgba(0,0,0,0.2); }
.modal-box.modal-lg { width: 820px; }
.modal-header { padding: 12px 16px; background: #f8fafc; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 16px; max-height: 78vh; overflow-y: auto; }

/* Toast & Global Loader */
.toast-container { position: fixed; right: 18px; bottom: 18px; z-index: 1200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: #1e293b; color: #fff; padding: 10px 14px; border-radius: 6px; font-size: 12.5px; box-shadow: 0 8px 20px rgba(0,0,0,0.18); transition: opacity 0.25s; pointer-events: auto; }
.toast-success { background: #15803d; }
.toast-error { background: #b91c1c; }
.toast-warn { background: #b45309; }
.toast.fade-out { opacity: 0; }

.global-loader { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 6px 14px; border-radius: 20px; font-size: 12px; z-index: 1300; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }

/* Responsive */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* Print (Invoices, Statements, Checks, Financial Reports) */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .sidebar, .topbar, .modal-backdrop, .toast-container, .global-loader, .no-print { display: none !important; }
  .app-shell, .main-area, .view-container { display: block !important; padding: 0 !important; margin: 0 !important; overflow: visible !important; }
  .card { border: none; box-shadow: none; break-inside: avoid; }
}