:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #dde4eb;
  --text: #1d2939;
  --muted: #667085;
  --primary: #14532d;
  --primary-soft: #dcfce7;
  --danger: #b42318;
  --shadow: 0 10px 28px rgba(16, 24, 40, 0.08);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
.app-shell { max-width: 1500px; margin: 0 auto; padding: 18px; }
.topbar, .panel { background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 18px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 18px 20px; margin-bottom: 18px; }
.topbar h1 { margin: 0 0 6px; font-size: 26px; }
.topbar p { margin: 0; color: var(--muted); }
.topbar-actions, .invoice-actions, .bottom-actions, .reports-toolbar, .modal-actions, .invoice-manager-toolbar { display: flex; flex-wrap: wrap; gap: 10px; }
button { border: 0; background: var(--primary); color: #fff; padding: 10px 14px; border-radius: 12px; cursor: pointer; font-weight: 600; }
button:hover { transform: translateY(-1px); }
.secondary-btn { background: #344054; }
.danger-btn { background: var(--danger); }
.icon-btn { background: transparent; color: var(--text); font-size: 20px; padding: 4px 8px; }
.main-grid { display: grid; gap: 18px; margin-bottom: 18px; }
.single-column { grid-template-columns: 1fr; }
.panel { padding: 18px; }
.panel-head, .bottom-head, .modal-header { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 16px; }
.panel-head h2, .modal-header h3 { margin: 0; font-size: 22px; }
.hint { color: var(--muted); font-size: 13px; }
.status-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.badge { background: #eff8ff; color: #175cd3; padding: 8px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.muted { background: #f2f4f7; color: #344054; }
.compact-entry { display: grid; grid-template-columns: 2fr 110px 150px 180px; gap: 12px; align-items: end; }
.entry-box label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.entry-readonly, .compact-entry input {
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px; min-height: 48px; display: flex; align-items: center; font-weight: 700;
}
.key-actions button { width: 100%; min-height: 48px; }
.bill-table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 14px; min-height: 260px; }
.bill-table, .report-table { width: 100%; border-collapse: collapse; }
.bill-table th, .bill-table td, .report-table th, .report-table td { padding: 12px; border-bottom: 1px solid #eef2f6; text-align: left; }
.empty-state { padding: 24px; text-align: center; color: var(--muted); }
.totals { margin-top: 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.totals > div { background: #f8fafc; border: 1px solid var(--border); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.totals .grand { background: var(--primary-soft); }
.totals strong { font-size: 24px; }
.invoice-actions { margin-top: 16px; }
.invoice-actions input, .invoice-manager-toolbar input { border: 1px solid var(--border); background: #fff; border-radius: 12px; padding: 10px 12px; min-width: 140px; }
.quick-keys-canvas {
  position: relative; min-height: 360px; border: 2px dashed #c7d3e0; border-radius: 18px; background:
  linear-gradient(to right, rgba(0,0,0,0.03) 1px, transparent 1px),
  linear-gradient(to bottom, rgba(0,0,0,0.03) 1px, transparent 1px),
  #fbfcfd;
  background-size: 24px 24px; overflow: hidden;
}
.quick-key {
  position: absolute; border-radius: 16px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px;
  text-align: center; padding: 10px; user-select: none; touch-action: none; box-shadow: 0 8px 16px rgba(16,24,40,.08);
}
.quick-key small { font-size: 12px; font-weight: 700; opacity: .95; }
.quick-key.selected { outline: 3px solid #22c55e; }
.quick-key.dragging { opacity: .85; }
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 40; }
.modal.hidden { display: none; }
.modal-card { width: min(620px, 100%); background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 18px; max-height: 90vh; overflow: auto; }
.modal-card.wide { width: min(1100px, 100%); }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 12px; }
.edit-grid label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.edit-grid input, .edit-grid select { width: 100%; }
.report-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }
.report-card { background: #f8fafc; border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.report-card .label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.report-card .value { font-size: 24px; font-weight: 700; }
.report-filter.active { background: #175cd3; }
.table-scroll { overflow: auto; border: 1px solid var(--border); border-radius: 14px; }
.line-edit-input { width: 84px; padding: 7px 8px; border: 1px solid var(--border); border-radius: 8px; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 1024px) {
  .compact-entry { grid-template-columns: 1fr 1fr; }
  .report-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .topbar, .panel-head, .bottom-head { flex-direction: column; align-items: stretch; }
  .compact-entry, .totals, .edit-grid, .report-cards { grid-template-columns: 1fr; }
}
@media print {
  .topbar-actions, .bottom-panel, .invoice-actions, .compact-entry, .delete-line-btn, #reportsBtn, #invoiceManagerBtn, #editLayoutBtn, #newInvoiceBtn { display: none !important; }
  body { background: #fff; }
  .app-shell { padding: 0; }
  .panel, .topbar { box-shadow: none; border: 0; }
}


.panel-head-right { display:flex; align-items:flex-end; gap:14px; flex-wrap:wrap; }
.panel-tools { display:flex; gap:8px; flex-wrap:wrap; }
.panel-tool-btn { background:#0f172a; color:#fff; padding:10px 14px; border-radius:12px; }
.panel-resizable { resize: vertical; overflow: auto; min-height: 220px; }
.panel-body.hidden-panel-body { display:none; }
.panel-collapsed { resize: none; }
.panel-collapsed .panel-head { margin-bottom: 0; }
.bottom-enter-wrap { display:flex; justify-content:center; padding-top:16px; }
.wide-enter-btn { min-width: 420px; max-width: 92%; width: 48%; min-height: 60px; font-size: 20px; border-radius: 16px; }
.panel-fullscreen {
  position: fixed !important;
  inset: 16px !important;
  z-index: 9999 !important;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
}
.panel-fullscreen .panel-body { height: calc(100% - 92px); overflow: auto; }
.panel-fullscreen .quick-keys-canvas { min-height: calc(100% - 92px); }
.bill-panel { min-height: 460px; }
.bottom-panel { min-height: 380px; }
@media (max-width: 900px) {
  .panel-head, .bottom-head, .modal-header { flex-direction: column; align-items: stretch; }
  .compact-entry { grid-template-columns: 1fr 1fr; }
  .wide-enter-btn { width: 100%; min-width: 0; }
}

.menu-fullscreen-exit-wrap { display:none; justify-content:flex-end; padding-bottom:12px; }
.hidden { display:none !important; }
.bottom-panel.menu-only-fullscreen { padding: 16px; }
.bottom-panel.menu-only-fullscreen .bottom-head { display:none !important; }
.bottom-panel.menu-only-fullscreen .menu-fullscreen-exit-wrap { display:flex; }
.bottom-panel.menu-only-fullscreen .panel-body { height: 100%; overflow: hidden; display:flex; flex-direction:column; }
.bottom-panel.menu-only-fullscreen .quick-keys-canvas { flex:1 1 auto; min-height: 0; }
.bottom-panel.menu-only-fullscreen .bottom-enter-wrap { padding-top: 12px; flex: 0 0 auto; }
.bottom-panel.menu-only-fullscreen .wide-enter-btn { width: 100%; max-width: 100%; min-height: 74px; font-size: 24px; }


.menu-action-status {
  flex: 1 1 260px;
  min-height: 56px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 700;
}
.menu-action-status.success {
  background: #ecfdf3;
  color: #027a48;
  border-color: #abefc6;
}
.menu-action-status.info {
  background: #eff8ff;
  color: #175cd3;
  border-color: #b2ddff;
}
.bottom-enter-wrap { align-items:center; gap:12px; flex-wrap:wrap; }
.bottom-enter-wrap .hidden { display:none !important; }
#menuFooterExitBtn { display:none; }
.bottom-panel.menu-only-fullscreen .menu-fullscreen-exit-wrap { display:none; }
.bottom-panel.menu-only-fullscreen #menuFooterExitBtn { display:inline-flex; align-items:center; justify-content:center; }
.bottom-panel.menu-only-fullscreen .bottom-enter-wrap { padding-top: 12px; flex: 0 0 auto; justify-content:space-between; }
.bottom-panel.menu-only-fullscreen .menu-action-status { order: 1; flex: 1 1 320px; min-height: 64px; font-size: 18px; }
.bottom-panel.menu-only-fullscreen .wide-enter-btn { order: 2; width: auto; flex: 0 1 420px; max-width: 420px; min-height: 74px; font-size: 24px; }
.bottom-panel.menu-only-fullscreen #menuFooterExitBtn { order: 3; min-height: 74px; padding: 0 24px; border-radius: 16px; }
@media (max-width: 900px) {
  .menu-action-status { flex-basis: 100%; }
  .bottom-panel.menu-only-fullscreen .wide-enter-btn,
  .bottom-panel.menu-only-fullscreen #menuFooterExitBtn { width: 100%; max-width: 100%; flex: 1 1 100%; }
}

/* ===== Added module styles: Dashboard, Inventory, Expenses, Local Database ===== */
.ultra-wide { width: min(1280px, calc(100vw - 36px)); max-height: 92vh; overflow: auto; }
.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.module-grid { display: grid; gap: 16px; margin-top: 16px; }
.two-modules { grid-template-columns: minmax(0, 1.4fr) minmax(280px, .8fr); }
.module-box { border: 1px solid var(--border); border-radius: 16px; padding: 14px; background: #fff; }
.module-box h4 { margin: 0 0 12px; }
.module-form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; margin-bottom: 14px; }
.module-form input, .module-form select, .invoice-manager-toolbar input { width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: #fff; color: var(--text); }
.small-scroll { max-height: 360px; }
.activity-list { display: grid; gap: 10px; max-height: 390px; overflow: auto; }
.activity-item { border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; background: #f8fafc; display: grid; gap: 3px; }
.activity-item strong { color: var(--primary); }
.activity-item span { color: var(--text); }
.activity-item small { color: var(--muted); }
.value.positive { color: #027a48; }
.value.negative { color: var(--danger); }
.db-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.db-preview { white-space: pre-wrap; background: #0f172a; color: #e2e8f0; border-radius: 16px; padding: 16px; max-height: 320px; overflow: auto; }
@media (max-width: 900px) { .two-modules { grid-template-columns: 1fr; } .ultra-wide { width: calc(100vw - 20px); } }
