/* ============================================================
   POSB ACCOUNTS REPORT – Stylesheet
   ============================================================ */

:root {
  --red:       #c0392b;
  --dark-red:  #922b21;
  --green:     #1e8449;
  --blue:      #1a5276;
  --bg:        #f5f7fa;
  --card:      #ffffff;
  --border:    #e0e0e0;
  --text:      #2c3e50;
  --muted:     #7f8c8d;
  --gold:      #d4ac0d;
  --light-red: #fdecea;
  --light-gold:#fef9e7;
  --radius:    10px;
  --shadow:    0 2px 10px rgba(0,0,0,.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
}

/* ── Loading ─────────────────────────────────────────────── */
.loading-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(255,255,255,.78); z-index: 999;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 14px;
}
.loading-overlay.active { display: flex; }
.spinner {
  width: 46px; height: 46px;
  border: 5px solid #f0d0ce; border-top-color: var(--red);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--red); font-weight: 600; }

/* ── Navbar ──────────────────────────────────────────────── */
.navbar {
  background: linear-gradient(135deg, var(--red), var(--dark-red));
  color: #fff; padding: 0 20px; height: 62px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 3px 12px rgba(0,0,0,.22);
  position: sticky; top: 0; z-index: 200;
}
.navbar-brand { display: flex; align-items: center; gap: 12px; }
.navbar-brand .emblem {
  width: 40px; height: 40px; background: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; flex-shrink: 0;
}
.navbar-brand h1 { font-size: 1.05rem; font-weight: 700; }
.navbar-brand p  { font-size: .7rem; opacity: .85; }
.navbar-actions { display: flex; gap: 8px; }
.navbar-actions a {
  color: #fff; text-decoration: none; font-size: .78rem; font-weight: 600;
  background: rgba(255,255,255,.15); padding: 6px 13px; border-radius: 6px;
  transition: .2s;
}
.navbar-actions a:hover { background: rgba(255,255,255,.28); }

/* ── Page Title ──────────────────────────────────────────── */
.page-title {
  background: linear-gradient(135deg, #2f3e94 0%, #3F51B5 60%, #333e7e 100%);
  color: #fff; text-align: center; padding: 8px 10px;
  font-size: 1.15rem; font-weight: 700; letter-spacing: .2px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  position: sticky; top: 62px; z-index: 190;
}

/* ── Layout ──────────────────────────────────────────────── */
.main-wrapper { max-width: 1500px; margin: 0 auto; padding: 18px 16px 40px; }

/* ── Report Type Radio ───────────────────────────────────── */
.rpt-type-card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px 24px; margin-bottom: 14px;
  box-shadow: var(--shadow);
  display: flex; gap: 40px; align-items: center;
  justify-content: center; flex-wrap: wrap;
  border: 2px solid #f5d5d0;
}
.radio-label {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: .95rem; font-weight: 600;
  color: var(--text); user-select: none;
}
.radio-label input[type=radio] { display: none; }
.radio-custom {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); background: #fff;
  transition: .2s; flex-shrink: 0;
  position: relative;
}
.radio-label input[type=radio]:checked + .radio-custom {
  border-color: var(--red); background: var(--red);
  box-shadow: 0 0 0 3px rgba(192,57,43,.15);
}
.radio-label input[type=radio]:checked + .radio-custom::after {
  content: ''; position: absolute;
  top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 7px; height: 7px; background: #fff; border-radius: 50%;
}
.radio-label:hover .radio-custom { border-color: var(--red); }

/* ── Filter Card ─────────────────────────────────────────── */
.filter-card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
  margin-bottom: 16px;
  border: 1px solid rgba(192,57,43,.1);
}
.filter-row {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
}
.filter-group {
  display: flex; flex-direction: column; gap: 4px;
  flex: 1; min-width: 130px;
}
.fg-month { max-width: 130px; min-width: 110px; }

.filter-group label {
  font-size: .72rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px;
}
.filter-group select {
  padding: 8px 28px 8px 10px; border: 2px solid var(--border);
  border-radius: 8px; font-size: .85rem; color: var(--text);
  background: #fafafa; cursor: pointer; outline: none;
  transition: .2s; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg fill='%23777' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat; background-position: right 6px center;
  background-size: 18px;
}
.filter-group select:focus  { border-color: var(--red); box-shadow: 0 0 0 3px rgba(192,57,43,.1); background-color: #fff; }
.filter-group select:disabled { opacity: .45; cursor: not-allowed; background-color: #f0f0f0; }

.filter-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: flex-end; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border: none; border-radius: 8px;
  font-size: .85rem; font-weight: 600; cursor: pointer;
  transition: .2s; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary  { background: var(--red);  color: #fff; box-shadow: 0 3px 8px rgba(192,57,43,.25); }
.btn-primary:hover:not(:disabled)  { background: var(--dark-red); transform: translateY(-1px); }
.btn-export   { background: var(--blue); color: #fff; box-shadow: 0 3px 8px rgba(26,82,118,.25); }
.btn-export:hover:not(:disabled)   { background: #154360; transform: translateY(-1px); }
.btn-reset    { background: #f0f0f0; color: var(--text); }
.btn-reset:hover { background: #e0e0e0; transform: translateY(-1px); }

/* ── Filter status row ───────────────────────────────────── */
.filter-status-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed #f0c8c4; font-size: .8rem;
}
.filter-status-label { color: var(--muted); font-weight: 600; }
.filter-status-badge {
  background: var(--red); color: #fff;
  padding: 2px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 700;
}
.period-badge {
  background: #1a5276; color: #fff;
  padding: 2px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 700;
  display: none;
}
.period-badge.show { display: inline-block; }
.filter-hint { color: var(--muted); font-size: .75rem; font-style: italic; }

/* ── Result info ─────────────────────────────────────────── */
.result-info {
  font-size: .85rem; font-weight: 600; color: var(--red);
  margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.result-badge {
  background: var(--light-red); border: 1px solid #f0c4bf;
  color: var(--red); padding: 2px 10px; border-radius: 20px;
  font-size: .78rem; font-weight: 700;
}
.view-badge {
  background: #eaf4ff; border: 1px solid #bee3f8;
  color: #1a5276; padding: 2px 10px; border-radius: 20px;
  font-size: .73rem; font-weight: 600;
}
.type-badge-opened { background: #eafaf1; border: 1px solid #a9dfbf; color: var(--green); padding: 2px 10px; border-radius: 20px; font-size: .73rem; font-weight: 700; }
.type-badge-closed { background: var(--light-red); border: 1px solid #f0c4bf; color: var(--red); padding: 2px 10px; border-radius: 20px; font-size: .73rem; font-weight: 700; }

/* ── Alert ───────────────────────────────────────────────── */
.alert { padding: 11px 14px; border-radius: 8px; font-size: .875rem; margin-bottom: 12px; }
.alert-error { background: var(--light-red); color: var(--red); border-left: 3px solid var(--red); }
.alert-warn  { background: #fff8e6; color: #7d5a00; border-left: 3px solid #f6c84e; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 10px; }
.empty-state h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 6px; }

/* ── Report Table ────────────────────────────────────────── */
.report-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.report-table {
  width: 100%; border-collapse: collapse;
  font-size: .8rem; background: #fff;
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}

/* Header */
.report-table thead th {
  padding: 9px 10px; font-weight: 700;
  text-align: center; white-space: nowrap;
}
.th-label {
  background: #d0e8f8; color: var(--red);
  border-right: 1px solid #e0c0bc;
  text-align: left !important;
}
.th-slno {
  background: #d0e8f8; color: var(--red);
  width: 40px; min-width: 36px;
  border-right: 1px solid #e0c0bc;
  text-align: center !important;
}
/* Opened scheme header = blue tint */
.th-scheme-opened {
  background: #d0e8f8; color: #b22222;
  cursor: pointer; user-select: none; transition: background .15s;
}
.th-scheme-opened:hover { background: #b8d8f0; }
/* Closed scheme header = green tint */
.th-scheme-closed {
  background: #d0e8f8; color: #b22222;
  cursor: pointer; user-select: none; transition: background .15s;
}
.th-scheme-closed:hover { background: #b0d0ac; }

/* Sort icons */
.sort-icon { display: inline-block; margin-left: 3px; font-size: .65rem; opacity: .35; }
.sort-icon.active { opacity: 1; color: #fff; }

/* Body */
.report-table tbody td {
  padding: 9px 10px; border-bottom: 1px solid #f0f0f0;
  text-align: center; vertical-align: middle;
}
.td-label { text-align: left !important; font-weight: 500; }
.td-slno  { text-align: center !important; color: var(--muted); font-size: .75rem; background: #fdf8f8; }

.report-table tbody tr:hover td { background: #fff8f7; }
.report-table tbody tr:nth-child(even) td { background: #fafafa; }
.report-table tbody tr:nth-child(even):hover td { background: #fff0ee; }

/* Total row */
.row-total td {
  background: var(--light-gold) !important;
  color: var(--red) !important;
  font-weight: 700 !important;
  border-top: 2px solid #f0d070 !important;
  font-size: .85rem !important;
}

/* ── Footer ──────────────────────────────────────────────── */
footer {
  text-align: center; padding: 18px; font-size: .76rem;
  color: #999; border-top: 1px solid #eee;
  background: #fff; margin-top: 20px;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .navbar-brand p { display: none; }
  .page-title { font-size: .9rem; top: 62px; }
}
@media (max-width: 640px) {
  .navbar { padding: 0 12px; height: 54px; }
  .page-title { top: 54px; font-size: .82rem; }
  .filter-group { min-width: 100%; }
  .fg-month { max-width: 100%; }
  .filter-actions { width: 100%; }
  .btn { flex: 1; justify-content: center; }
  .report-table { font-size: .75rem; }
  .rpt-type-card { gap: 20px; padding: 12px 16px; }
}
@media print {
  .navbar, .rpt-type-card, .filter-card, .navbar-actions { display: none !important; }
  .page-title { position: static; }
  .sort-icon { display: none; }
}
