/* MangoCloud Expense Dashboard
   Brand: #FDCB4E (mango yellow), #555556 (dark grey), white bg */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: #555556;
  background: #fff;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Top Bar — sticky, thin, logo left / user right */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  position: sticky;
  top: 0;
  z-index: 100;
  height: 48px;
}
.top-bar-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.top-bar-left .logo { height: 28px; }
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: #888;
}
.logout-link { color: #999; text-decoration: none; }
.logout-link:hover { color: #555556; }

/* Main content area */
.container { padding: 1rem 1.5rem 2rem; }
.container h1 { font-size: 1.3rem; margin-bottom: 1rem; }

/* Table container — horizontal scroll on mobile */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* P&L Table — class name matches JS: "pnl-table" */
.pnl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 640px;
}
.pnl-table th,
.pnl-table td {
  padding: 0.55rem 0.75rem;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid #f0f0f0;
}
/* First column: left-aligned category name, sticky on horizontal scroll */
.pnl-table th:first-child,
.pnl-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 2;
  min-width: 160px;
}
.pnl-table thead th {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #999;
  border-bottom: 2px solid #e8e8e8;
  background: #fff;
}
.pnl-table tbody td {
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
}
/* Clickable cells */
.pnl-cell { cursor: pointer; }
/* Mango yellow hover highlight — single cell only */
.pnl-cell:hover {
  background: rgba(253, 203, 78, 0.12);
}
/* Bold business total row */
.total-row td {
  font-weight: 700;
  border-top: 2px solid #555556;
  border-bottom: 2px solid #555556;
  font-size: 1rem;
}
/* Group header row — bold label, light shading, spans full width */
.group-header-row td {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #f7f7f7;
  color: #777;
  border-bottom: 1px solid #e8e8e8;
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
}
/* Indented category name under a group */
.cat-indent { padding-left: 1.5rem !important; }
/* Group subtotal row — semi-bold, subtle top border */
.group-subtotal-row td {
  font-weight: 600;
  font-size: 0.9rem;
  color: #666;
  border-top: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
}
/* Sticky first-column backgrounds for new row types */
.group-header-row td:first-child { background: #f7f7f7; }
.group-subtotal-row td:first-child { background: #fff; }
/* Muted personal row */
.personal-row td { color: #aaa; font-style: italic; }

/* Slide-out panel overlay */
.panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 200;
}
.panel-overlay.open { display: block; }

/* Right panel — line items list (slides from right) */
.panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 30%;
  height: 100%;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
  z-index: 210;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  padding: 1.5rem;
}
.panel.open { transform: translateX(0); }

/* Left detail panel — invoice preview + edit (slides from left) */
.detail-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 70%;
  height: 100%;
  background: #fff;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
  z-index: 220;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  padding: 1.5rem 2rem;
}
.detail-panel.open { transform: translateX(0); }

/* Panel header (used by both panels) */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e8e8e8;
}
.panel-header h2 { font-weight: 700; font-size: 1.05rem; color: #555556; flex: 1; }
.panel-close, .panel-back {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: #999;
  padding: 0.25rem;
  line-height: 1;
}
.panel-close:hover, .panel-back:hover { color: #555556; }

/* Line items list */
.line-items-list { display: flex; flex-direction: column; gap: 0.25rem; }
.line-item {
  padding: 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}
.line-item:hover { background: rgba(253, 203, 78, 0.08); }
.line-item.active {
  background: rgba(253, 203, 78, 0.18);
  border-left: 3px solid #FDCB4E;
}
.line-item-primary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.95rem;
}
.line-item-vendor { font-weight: 600; }
.line-item-amount { font-variant-numeric: tabular-nums; }
.line-item-secondary {
  font-size: 0.8rem;
  color: #999;
  margin-top: 0.2rem;
  display: flex;
  gap: 0.5rem;
}

/* Invoice preview */
.preview-container { margin-bottom: 1.5rem; }
.preview-img { max-width: 100%; max-height: 60vh; border-radius: 4px; border: 1px solid #e8e8e8; }
.preview-pdf { width: 100%; height: 60vh; border: 1px solid #e8e8e8; border-radius: 4px; }
.preview-hidden { display: none; }
.preview-loading {
  padding: 2rem;
  text-align: center;
  color: #999;
  font-size: 0.9rem;
  border: 1px dashed #ddd;
  border-radius: 4px;
  background: #fafafa;
}
.preview-unavailable { color: #999; font-style: italic; }

/* Edit form */
.edit-form { margin-top: 1rem; max-width: 420px; }
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #999;
  margin-bottom: 0.3rem;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: #555556;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  transition: border-color 0.15s ease;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #FDCB4E;
  box-shadow: 0 0 0 2px rgba(253, 203, 78, 0.25);
}
.form-group input[type="number"] {
  font-variant-numeric: tabular-nums;
}
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.btn-save, .btn-cancel {
  padding: 0.5rem 1.2rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-save { background: #FDCB4E; color: #555556; }
.btn-save:hover { background: #fdc220; }
.btn-cancel { background: #f5f5f5; color: #555556; }
.btn-cancel:hover { background: #e8e8e8; }

#save-status { margin-top: 0.75rem; font-size: 0.85rem; color: #999; }

/* Login page */
.login-body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #fafafa;
}
.login-card {
  text-align: center;
  background: #fff;
  padding: 3rem 2.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}
.login-logo { height: 48px; margin-bottom: 1rem; }
.login-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.login-subtitle { color: #999; margin-bottom: 2rem; }
.google-signin-btn {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: #FDCB4E;
  color: #555556;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border-radius: 4px;
  transition: background 0.15s ease;
}
.google-signin-btn:hover { background: #fdc220; }

/* Responsive: mobile <= 768px */
@media (max-width: 768px) {
  .top-bar { padding: 0.5rem 1rem; }
  .container { padding: 0.75rem; }
  .panel { width: 100%; }
  .detail-panel { width: 100%; }
  .pnl-table { font-size: 0.82rem; }
  .pnl-table tbody td { font-size: 0.85rem; }
  .pnl-table th, .pnl-table td { padding: 0.45rem 0.5rem; }
}
