:root {
  --brand: #006838;
  --brand-dark: #00532c;
  --accent: #b7785f;
  --sand: #eae2d5;
  --sand-light: #f6f2eb;
  --high: #e53e3e;
  --medium: #dd6b20;
  --low: #38a169;
  --bg: #f7f8fa;
  --border: #e2e8f0;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: #1a202c;
}

.hidden { display: none !important; }

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: white;
  padding: 40px;
  border-radius: 12px;
  border-top: 4px solid var(--brand);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  text-align: center;
  max-width: 320px;
}
.login-logo { display: block; margin: 0 auto 18px; height: 76px; width: auto; }
.ms-login-btn {
  display: inline-block;
  margin-top: 20px;
  background: var(--brand);
  color: white;
  padding: 12px 20px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
}

.topbar {
  background: white;
  border-bottom: 3px solid var(--brand);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--brand-dark); display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 44px; width: auto; display: block; }
.userbox { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; }
.link-btn {
  background: none; border: none; color: var(--brand); cursor: pointer; font-size: 0.9rem;
  padding: 6px 8px; border-radius: 6px;
}
.link-btn:hover { background: var(--sand-light); }

.layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 16px;
  padding: 16px;
  max-width: 1300px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}
.panel h2 { margin-top: 0; font-size: 1.05rem; }

.list-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters select { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); }

button.primary {
  padding: 8px 14px;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
button.secondary {
  padding: 8px 14px;
  background: white;
  color: #4a5568;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

.invoice-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.invoice-row:hover { background: #f7f8fa; }
.invoice-row.selected { background: var(--sand-light); }
.invoice-row .vendor { font-weight: 700; }
.invoice-row .meta { font-size: 0.8rem; color: #718096; }
.invoice-row .total { font-weight: 700; text-align: right; white-space: nowrap; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}
.tag-high { background: var(--low); }
.tag-medium { background: var(--medium); }
.tag-low { background: var(--high); }
.tag-pending_review { background: var(--medium); }
.tag-approved { background: var(--low); }
.tag-rejected { background: var(--high); }
.tag-booked { background: var(--brand); }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

form label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #4a5568;
}
form input, form select, form textarea {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 400;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.line-items-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.line-items-table th, .line-items-table td {
  text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--border); font-size: 0.85rem;
}

.attachment-preview {
  width: 100%;
  height: 500px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 14px;
}

.action-row { display: flex; gap: 8px; margin-top: 16px; }

.empty-state { text-align: center; color: #718096; padding: 40px 0; }

.notes-box {
  background: #fffaf0;
  border: 1px solid #feebc8;
  border-radius: 6px;
  padding: 10px;
  font-size: 0.85rem;
  margin-top: 10px;
}


/* ---- Reconciliation view ---- */

.muted {
  color: #666;
  font-size: 0.9em;
}

.primary-btn {
  background: #1f4e78;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95em;
  margin-right: 8px;
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.recon-summary {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.recon-card {
  background: #f5f7fa;
  border: 1px solid #e0e4e8;
  border-radius: 6px;
  padding: 12px 20px;
  min-width: 140px;
  text-align: center;
}

.recon-num {
  font-size: 1.8em;
  font-weight: bold;
  color: #1f4e78;
}

.recon-label {
  font-size: 0.85em;
  color: #666;
  margin-top: 4px;
}

.recon-section {
  border-top: 1px solid #e0e4e8;
  padding: 16px 0;
}

.recon-section h3 {
  margin-top: 0;
}

.suggestion-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

.suggestion-left, .suggestion-right {
  flex: 1 1 0;
}

.suggestion-arrow {
  font-size: 1.2em;
  color: #999;
}

.suggestion-actions {
  display: flex;
  gap: 8px;
}

.suggestion-actions button {
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid #ccc;
  cursor: pointer;
  background: #fff;
}

.confirm-match-btn {
  border-color: #2e7d32 !important;
  color: #2e7d32;
}

.dismiss-match-btn {
  border-color: #999 !important;
  color: #666;
}

.bankfee-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

.bankfee-actions {
  display: flex;
  gap: 8px;
}

.bankfee-actions button {
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid #ccc;
  cursor: pointer;
  background: #fff;
}

.approve-bankfee-btn {
  border-color: #2e7d32 !important;
  color: #2e7d32;
}

.unapprove-bankfee-btn {
  border-color: #999 !important;
  color: #666;
}

.status-pending { color: #b26a00; }
.status-approved { color: #1565c0; }
.status-posted { color: #2e7d32; }


/* ---- Reconciliation redesign: full-width layout + missing class fixes ---- */

/* The reconciliation view has only one panel, so the page-wide .layout grid
   (420px sidebar + 1fr) was leaving it stuck in the narrow 420px column with
   the rest of the page blank. Let it span the full width instead. */
#reconcileLayout .panel {
  grid-column: 1 / -1;
}

/* Petty Cash tab: same full-width fix as reconciliation, plus a wider
   single-column layout (it only has one recon-col, no side-by-side content)
   and slightly larger type per user request for easier reading. */
#pettyCashLayout .panel {
  grid-column: 1 / -1;
}
#pettyCashLayout .recon-grid {
  grid-template-columns: 1fr;
  max-width: 1100px;
  margin: 8px auto 0;
}
#pettyCashLayout .recon-card {
  font-size: 1.05em;
}
#pettyCashLayout h2, #pettyCashLayout h3, #pettyCashLayout h4 {
  font-size: 1.15em;
}

.recon-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
  align-items: start;
  margin-top: 8px;
}
@media (max-width: 900px) {
  .recon-grid { grid-template-columns: 1fr; }
}
.recon-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.recon-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  border-top: none;
}
.recon-card h3 {
  margin-top: 0;
}

/* app.js renders summary counts as <div class="recon-stat"> -- give it the
   card look the unused .recon-card/.recon-num/.recon-label rules intended. */
.recon-stat {
  background: #f5f7fa;
  border: 1px solid #e0e4e8;
  border-radius: 8px;
  padding: 14px 20px;
  min-width: 140px;
  text-align: center;
}
.recon-stat strong {
  display: block;
  font-size: 1.6em;
  font-weight: 700;
  color: #1f4e78;
}
.recon-stat span {
  display: block;
  font-size: 0.82em;
  color: #666;
  margin-top: 4px;
}

/* app.js renders suggestion rows with .suggestion-invoice/.suggestion-tx
   (only .suggestion-left/.suggestion-right had rules) and expense-claim
   rows with .confirm-claim-btn/.dismiss-claim-btn (only the -match- variants
   had rules), so both were rendering unstyled. */
.suggestion-invoice, .suggestion-tx {
  flex: 1 1 0;
  min-width: 0;
}
.suggestion-tx {
  text-align: right;
}
.suggestion-row {
  flex-wrap: wrap;
}
.suggestion-actions {
  flex-wrap: wrap;
}
.confirm-claim-btn {
  border-color: #2e7d32 !important;
  color: #2e7d32;
}
.dismiss-claim-btn {
  border-color: #999 !important;
  color: #666;
}


/* ---- Mobile responsiveness pass ---- */

/* iOS Safari zooms the whole page in when a focused input's font-size is
   under 16px. Several inputs (petty-cash fund fields, assignment fields)
   live in a plain <div>, not a <form>, so the old ".form input {...}" rule
   never reached them and they fell back to the browser default (~13px).
   Forcing 16px here, on the elements themselves, fixes that everywhere. */
input, select, textarea {
  font-size: 16px;
}

.link-btn {
  padding: 6px 4px;
}

.petty-cash-assign-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.petty-cash-assign-row .assign-name {
  min-width: 160px;
}

.petty-cash-fund-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.9em;
}
.petty-cash-fund-row.voided {
  display: block;
}

.mobile-back-link {
  display: none;
}
@media (max-width: 900px) {
  .mobile-back-link {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--brand);
    font-weight: 600;
    text-decoration: none;
  }
}
@media (max-width: 640px) {
  .petty-cash-fund-row {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }
  .userbox {
    flex-wrap: wrap;
    gap: 8px 14px;
    font-size: 0.95rem;
  }
  .layout {
    padding: 10px;
    gap: 12px;
  }
  .panel {
    padding: 14px;
  }
  .field-row {
    grid-template-columns: 1fr;
  }
  .invoice-row {
    flex-wrap: wrap;
  }
  .invoice-row .total {
    margin-left: auto;
  }
  .detail-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .action-row {
    flex-wrap: wrap;
  }
  .action-row button {
    flex: 1 1 auto;
  }
  /* Simple data tables (line items, petty cash / bank fee history) don't
     reflow well at this width -- let them scroll horizontally instead of
     squeezing every column unreadably thin. */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Petty cash "add to fund" and "assign employee" controls are laid out
     with fixed pixel widths (meant for desktop); stack them full-width so
     nothing gets clipped or too small to tap accurately. */
  #pettyCashFundBox, #pettyCashFundAmount, #pettyCashFundCurrency,
  #pettyCashFundNote, #pettyCashAssignName, #pettyCashAssignBox {
    width: 100% !important;
  }
  .petty-cash-assign-row {
    flex-wrap: wrap;
  }
  .petty-cash-assign-row .assign-name {
    min-width: 0;
    flex: 1 1 100%;
  }
}


/* ---- Operations Hub landing page ---- */
.hub-back-link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.2rem;
  margin-right: 2px;
}
.hub-back-link:hover { opacity: 0.7; }

.hub-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}
.dept-block { margin-bottom: 36px; }
.dept-block h2 {
  color: var(--brand-dark);
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--sand);
  padding-bottom: 8px;
  margin-bottom: 18px;
}
.dept-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}
.dept-tile {
  display: block;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s, transform 0.15s;
}
.dept-tile:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.dept-tile h3 {
  margin: 0 0 6px;
  color: var(--brand-dark);
  font-size: 1rem;
}
.dept-tile .muted { margin: 0 0 12px; }
.stat-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--sand-light);
  color: var(--brand-dark);
}
.stat-badge.badge-warn {
  background: #fff5f0;
  color: var(--high);
}
.staff-hub-message {
  max-width: 480px;
  margin: 60px auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
}
@media (max-width: 640px) {
  .dept-tiles { grid-template-columns: 1fr; }
}


/* ---- Dushi Rentals aesthetic pass: branded login + hub polish ---- */

.center-screen {
  background:
    radial-gradient(circle at 15% 20%, rgba(0,104,56,0.10), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(183,120,95,0.12), transparent 45%),
    linear-gradient(160deg, var(--sand-light) 0%, var(--bg) 60%);
  position: relative;
  overflow: hidden;
}
.login-card {
  border-radius: 16px;
  border-top: none;
  box-shadow: 0 12px 40px rgba(0,83,44,0.16);
  position: relative;
}
.login-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}
.login-logo { height: 84px; }

.hub-layout {
  background: linear-gradient(180deg, var(--sand-light) 0%, var(--bg) 220px);
}
.dept-tile {
  border-left: 4px solid var(--brand);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#hub .dept-block:nth-of-type(2) .dept-tile,
.dept-block.operations .dept-tile {
  border-left-color: var(--accent);
}
.dept-tile .dept-icon {
  width: 30px;
  height: 30px;
  margin-bottom: 8px;
  color: var(--brand);
}
.dept-block.operations .dept-icon {
  color: var(--accent);
}
.dept-tile h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}
