:root {
  --topbar-blue: #2f6f97;
  --topbar-blue-dark: #235a7c;
  --tab-bg: #f4f6f8;
  --tab-border: #e2e6ea;
  --card-pink: #e6396b;
  --card-teal: #12798c;
  --card-green: #3f9142;
  --card-amber: #c07f17;
  --card-red: #e64545;
  --card-navy: #2d3f7c;
  --ink: #2b333a;
  --muted: #6c7a86;
  --bg: #eef1f4;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  margin: 0;
}

a { text-decoration: none; }

/* ---------------- Top bar ---------------- */
.app-topbar { box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.brand-row {
  background: linear-gradient(90deg, var(--topbar-blue), var(--topbar-blue-dark));
  color: #fff;
  display: flex;
  align-items: center;
  padding: 10px 20px;
  gap: 20px;
  flex-wrap: wrap; /* on narrow screens the actions drop to a second line instead of overflowing */
  row-gap: 8px;
}

.brand { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; font-weight: 700; }
.brand-mark {
  background: #fff;
  color: var(--topbar-blue);
  width: 38px; height: 38px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
/* Uploaded company logo — sits in a white tile like the reference design */
.brand-logo {
  background: #fff;
  border-radius: 8px;
  height: 44px;
  padding: 4px 8px;
  display: flex; align-items: center;
}
.brand-logo img { max-height: 36px; max-width: 170px; object-fit: contain; display: block; }
.logo-preview { min-height: 70px; display: flex; align-items: center; justify-content: center; background: var(--tab-bg); border-radius: 8px; padding: 10px; }
.logo-preview img { max-height: 80px; max-width: 100%; object-fit: contain; }
.brand-accent { color: #f5821f; font-weight: 800; }
.brand-company { flex: 1; min-width: 0; font-size: .85rem; color: rgba(255,255,255,.85); }
@media (max-width: 575.98px) { .brand-logo img { max-width: 110px; } }

.brand-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; order: 4; }
/* Search box in the header — inline on wide screens, its own line below the brand on narrower ones */
.brand-search { position: relative; flex: 0 1 360px; order: 3; }
.brand-search input {
  width: 100%; border-radius: 8px; border: 1px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.14); color: #fff; padding: 7px 12px 7px 32px; font-size: .88rem;
}
.brand-search input::placeholder { color: rgba(255,255,255,.78); }
.brand-search input:focus { background: #fff; color: #1f2937; border-color: #fff; outline: none; }
.brand-search > i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,.85); font-size: .85rem; pointer-events: none; }
.brand-search:focus-within > i { color: #6b7280; }
@media (max-width: 1199.98px) { .brand-search { order: 5; flex: 1 1 100%; } }
.btn-topbar {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: .85rem;
}
.btn-topbar:hover { background: rgba(255,255,255,.22); color: #fff; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; color: var(--topbar-blue);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
}

.module-tabs {
  background: var(--tab-bg);
  border-bottom: 1px solid var(--tab-border);
  display: flex;
  overflow-x: auto;
  padding: 0 10px;
}
.module-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  padding: 10px 18px;
  font-size: .78rem;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.module-tab i { font-size: 1.05rem; }
.module-tab .module-tab-ext { font-size: .6rem; margin-left: 2px; opacity: .7; }
@media (max-width: 991.98px) { .module-tab { padding: 10px 12px; } }
.module-tab:hover { color: var(--topbar-blue); background: rgba(47,111,151,.06); }
.module-tab.active {
  color: var(--topbar-blue);
  border-bottom-color: var(--topbar-blue);
  background: #fff;
  font-weight: 600;
}

/* ---------------- Main content ---------------- */
.app-main { max-width: 1400px; margin: 0 auto; padding: 22px 20px 40px; }

/* ---------------- Stat cards ---------------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
@media (max-width: 1100px) { .stat-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  border-radius: 8px;
  padding: 16px 18px;
  color: #fff;
  min-height: 92px;
  display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  transition: transform .15s ease;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .85rem; opacity: .95; margin-top: 6px; }
.stat-card .stat-label i { margin-right: 6px; }
.stat-card.pink { background: var(--card-pink); }
.stat-card.teal { background: var(--card-teal); }
.stat-card.green { background: var(--card-green); }
.stat-card.amber { background: var(--card-amber); }
.stat-card.red { background: var(--card-red); }
.stat-card.navy { background: var(--card-navy); }

/* ---------------- Panels / charts ---------------- */
.panel {
  background: #fff;
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  margin-bottom: 20px;
}
.panel h5 { text-align: center; font-weight: 700; color: var(--ink); margin-bottom: 14px; }
.chart-box { position: relative; height: 280px; }

/* ---------------- Inventory sub-nav pills ---------------- */
.subnav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.subnav-pill {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 600;
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--tab-border);
}
.subnav-pill:hover { color: var(--topbar-blue); border-color: var(--topbar-blue); }
.subnav-pill.active { background: var(--topbar-blue); color: #fff; border-color: var(--topbar-blue); }

/* ---------------- Landing module cards ---------------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tile-card {
  background: #fff;
  border-radius: 8px;
  padding: 22px 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  color: var(--ink);
  display: block;
  border-left: 4px solid var(--topbar-blue);
  transition: box-shadow .15s ease, transform .15s ease;
}
.tile-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.12); transform: translateY(-2px); color: var(--ink); }
.tile-card i { font-size: 1.6rem; color: var(--topbar-blue); margin-bottom: 10px; display: block; }
.tile-card .tile-title { font-weight: 700; margin-bottom: 4px; }
.tile-card .tile-desc { font-size: .82rem; color: var(--muted); }

/* ---------------- Cards / forms / tables ---------------- */
.card { border: none; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.card-header { background: #fff; border-bottom: 1px solid #eef0f2; font-weight: 700; border-radius: 8px 8px 0 0 !important; }
.table thead th { background: #f8fafb; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); border-bottom-width: 1px; }
.table td, .table th { vertical-align: middle; }
.text-dr { color: var(--card-teal); font-weight: 600; }
.text-cr { color: var(--card-red); font-weight: 600; }

.btn-primary { background: var(--topbar-blue); border-color: var(--topbar-blue); }
.btn-primary:hover { background: var(--topbar-blue-dark); border-color: var(--topbar-blue-dark); }

.voucher-line-table input, .voucher-line-table select { min-width: 110px; }
.voucher-totals { max-width: 380px; margin-left: auto; }
.voucher-totals .row { padding: 4px 0; }

/* ---------------- Invoice line items (responsive — no horizontal scroll) ---------------- */
.invoice-lines { margin-bottom: 14px; }
.invoice-line {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 14px;
  padding: 14px;
  border: 1px solid var(--tab-border);
  border-radius: 8px;
  margin-bottom: 10px;
  position: relative;
  background: #fff;
}
.invoice-line .line-item { grid-column: 1 / -1; }
.line-field label { display: block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 4px; }
.line-amount-box { background: var(--tab-bg); border-radius: 6px; padding: 9px 10px; font-weight: 700; text-align: right; }
.remove-line-btn { position: absolute; top: 10px; right: 10px; }

@media (min-width: 640px) {
  .invoice-line { grid-template-columns: repeat(4, 1fr); align-items: end; }
  .invoice-line .line-item { grid-column: 1 / span 2; }
}
@media (min-width: 980px) {
  .invoice-line { grid-template-columns: 2.2fr 1.1fr 0.8fr 0.9fr 0.7fr 1fr 34px; }
  .invoice-line .line-item { grid-column: auto; }
  .remove-line-btn { position: static; }
}

/* ---------------- Complaint status badges (existing palette) ---------------- */
.badge-status-open { background: color-mix(in srgb, var(--card-amber) 15%, white); color: var(--card-amber); border: 1px solid color-mix(in srgb, var(--card-amber) 35%, white); }
.badge-status-progress { background: color-mix(in srgb, var(--card-teal) 15%, white); color: var(--card-teal); border: 1px solid color-mix(in srgb, var(--card-teal) 35%, white); }
.badge-status-resolved { background: color-mix(in srgb, var(--card-green) 15%, white); color: var(--card-green); border: 1px solid color-mix(in srgb, var(--card-green) 35%, white); }
.badge-status-closed { background: #f1f2f4; color: var(--muted); border: 1px solid var(--tab-border); }
.status-badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: .78rem; font-weight: 700; }

.remark-item { border-left: 3px solid var(--topbar-blue); padding: 10px 14px; margin-bottom: 10px; background: var(--tab-bg); border-radius: 0 6px 6px 0; }
.remark-item .remark-meta { font-size: .75rem; color: var(--muted); margin-bottom: 4px; }

.badge-status-rejected { background: color-mix(in srgb, var(--card-red) 12%, white); color: var(--card-red); border: 1px solid color-mix(in srgb, var(--card-red) 35%, white); }

/* ---------------- HR: attendance status colours (existing palette) ---------------- */
.att-present      { --att: var(--card-green); }
.att-late         { --att: var(--card-amber); }
.att-half_day     { --att: #d9822b; }
.att-absent       { --att: var(--card-red); }
.att-paid_leave   { --att: var(--card-teal); }
.att-unpaid_leave { --att: var(--card-pink); }
.att-holiday      { --att: var(--card-navy); }
.att-chip {
  display: inline-block; min-width: 26px; padding: 2px 6px; border-radius: 6px;
  font-size: .72rem; font-weight: 700; text-align: center;
  color: var(--att); background: color-mix(in srgb, var(--att) 14%, white);
}

/* Attendance marking: one card-like row per employee that wraps on narrow panes */
.att-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 14px; border-bottom: 1px solid var(--tab-border); }
.att-row:last-child { border-bottom: none; }
.att-row .att-who { flex: 1 1 200px; min-width: 0; }
.att-row .att-status { flex: 0 0 160px; }
.att-row .att-remarks { flex: 1 1 180px; }
.att-row select.form-select { border-left: 4px solid var(--att, var(--tab-border)); }

/* Monthly register: a read-only matrix, so it scrolls — but the name and
   totals are pinned first so the useful part never needs scrolling. */
.register-table { font-size: .78rem; white-space: nowrap; }
.register-table th, .register-table td { padding: 5px 6px; text-align: center; }
.register-table .reg-name { position: sticky; left: 0; background: #fff; text-align: left; z-index: 1; box-shadow: 1px 0 0 var(--tab-border); }
.register-table thead .reg-name { background: #f8fafb; }
.register-table .reg-sunday { background: var(--tab-bg); }
.register-table .reg-total { font-weight: 700; }

/* Payslip */
.payslip-amount-words { font-style: italic; color: var(--muted); }
.payslip-net { font-size: 1.4rem; font-weight: 800; color: var(--card-teal); }

/* ---------------- Login page ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--topbar-blue), var(--card-navy));
}
.login-card {
  background: #fff; border-radius: 12px; padding: 36px 32px;
  width: 100%; max-width: 380px;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.login-card .brand-mark { margin: 0 auto 14px; }
.setup-card { max-width: 560px; }
.login-card .brand-logo { display: inline-flex; height: 70px; margin: 0 auto 10px; box-shadow: 0 1px 6px rgba(0,0,0,.08); }
.login-card .brand-logo img { max-height: 60px; max-width: 240px; }

/* ---------------- Print (invoice) ---------------- */
/* Company letterhead: invisible on screen, printed at the top of every page's printout */
.print-letterhead { display: none; }
.print-letterhead img { max-height: 64px; max-width: 220px; object-fit: contain; }
.print-letterhead-name { font-size: 1.25rem; font-weight: 800; }
.print-letterhead-meta { font-size: .8rem; color: #444; }
.doc-logo { max-height: 60px; max-width: 200px; object-fit: contain; display: block; margin-bottom: 6px; }

/* Find box above long dropdowns (customers, ledgers) */
.select-search { position: relative; margin-bottom: 4px; }
.select-search > .fa-magnifying-glass { position: absolute; left: 9px; top: 8px; font-size: .75rem; color: #8a94a6; pointer-events: none; }
.select-search input { padding-left: 26px; padding-right: 70px; }
.select-search-status { position: absolute; right: 9px; top: 5px; pointer-events: none; }

/* Rights Assignment matrix */
.rights-table th:not(:first-child), .rights-table td:not(:first-child) { width: 76px; }
.rights-table td { vertical-align: middle; }
.rights-table .form-check-input { width: 1.15em; height: 1.15em; margin: 0; cursor: pointer; }
.rights-group td { background: var(--tab-bg); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #4a5568; }
.rights-hint { font-size: .68rem; color: #8a94a6; line-height: 1.1; margin-top: 3px; }
.copy-targets { max-height: 180px; overflow-y: auto; }
@media (max-width: 575.98px) {
  .rights-table th:not(:first-child), .rights-table td:not(:first-child) { width: 46px; padding-left: 2px; padding-right: 2px; }
  .rights-table th { font-size: .72rem; }
  .rights-hint { display: none; }
}

@media print {
  .app-topbar, .app-footer, .no-print { display: none !important; }
  .app-main { padding: 0; max-width: 100%; }
  body { background: #fff; }
  .print-letterhead {
    display: flex; align-items: center; gap: 14px;
    border-bottom: 2px solid #333; padding-bottom: 8px; margin-bottom: 16px;
  }
}
