/* ============================================================
   Funds Dashboard — main.css
   ============================================================ */

/* ---- Reset & base ---------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f4f6f9;
  --surface:     #ffffff;
  --border:      #dde1e9;
  --text:        #1a1d23;
  --text-muted:  #6b7280;
  --primary:     #1f4e79;
  --primary-lt:  #d6e4f0;
  --accent:      #2563eb;
  --danger:      #dc2626;
  --success-bg:  #d1fae5;
  --success-txt: #065f46;
  --error-bg:    #fee2e2;
  --error-txt:   #991b1b;
  --subtotal-bg: #eef4fa;
  --grand-bg:    #1f4e79;
  --grand-txt:   #ffffff;
  --font:        'Segoe UI', system-ui, -apple-system, sans-serif;
  --radius:      6px;
  --shadow:      0 1px 4px rgba(0,0,0,.08);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Top nav --------------------------------------------- */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--primary);
  color: #fff;
  padding: 0 24px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
}

.nav-brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .3px;
  color: #fff;
}

.nav-links { display: flex; gap: 4px; }

.nav-links a {
  color: rgba(255,255,255,.82);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  transition: background .15s;
}

.nav-links a:hover,
.nav-links a.active {
  background: rgba(255,255,255,.18);
  color: #fff;
  text-decoration: none;
}

/* ---- Page wrapper ---------------------------------------- */
.page-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
}

.page-header { margin-bottom: 20px; }
.page-header h2 { font-size: 20px; font-weight: 700; }
.page-sub { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ---- Toolbar --------------------------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  flex: 1;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: .4px;
}

.filter-group input,
.filter-group select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  min-width: 130px;
}

.toolbar-actions { display: flex; gap: 8px; align-items: center; }

/* ---- Buttons --------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #163d61; }

.btn-accent   { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #1d4ed8; }

.btn-outline  { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }

.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-sm  { padding: 6px 12px; font-size: 12px; }
.btn-xs  { padding: 4px 8px;  font-size: 11px; }
.btn-full { width: 100%; justify-content: center; }

/* ---- Alerts ---------------------------------------------- */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
}

.alert-success { background: var(--success-bg); color: var(--success-txt); }
.alert-error   { background: var(--error-bg);   color: var(--error-txt); }

/* ---- Table ----------------------------------------------- */
.table-scroll { overflow-x: auto; border-radius: var(--radius); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}

.data-table th {
  background: var(--primary);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .3px;
  white-space: nowrap;
}

.data-table th.num-col,
.data-table td.num-col {
  text-align: right;
}

.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table .data-row:hover td { background: #f8fafc; }

.subtotal-row td {
  background: var(--subtotal-bg);
  font-size: 13px;
}

.grand-total-row td {
  background: var(--grand-bg);
  color: var(--grand-txt);
  font-weight: 700;
  font-size: 13px;
}

.null-val { color: var(--text-muted); }
.empty-cell { text-align: center; color: var(--text-muted); padding: 24px; }
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.mono { font-family: monospace; font-size: 12px; }

/* ---- Badge ----------------------------------------------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-lt);
  color: var(--primary);
}

.badge-green { background: var(--success-bg); color: var(--success-txt); }
.badge-gray  { background: #f3f4f6; color: var(--text-muted); }

/* ---- Config inline form ---------------------------------- */
.inline-form { display: inline; }

.select-inline {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  background: var(--bg);
  cursor: pointer;
}

/* ---- Modal ----------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
}

.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: 8px;
  width: 640px;
  max-width: 96vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,.22);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.modal-body {
  overflow-y: auto;
  padding: 16px 20px;
  flex: 1;
}

/* ---- Toast ----------------------------------------------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--primary);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  z-index: 300;
  box-shadow: 0 4px 16px rgba(0,0,0,.22);
  transition: opacity .3s;
}

.toast.hidden { display: none; }
.toast.toast-error { background: var(--danger); }

/* ---- Login page ------------------------------------------ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 40px 36px;
  width: 360px;
  box-shadow: var(--shadow);
}

.login-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-sub { color: var(--text-muted); font-size: 12px; margin-bottom: 28px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field label { font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); }
.field input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}
.field input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* ---- Link section ---------------------------------------- */
.link-section { margin-top: 24px; }
.link-hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ---- Responsive ------------------------------------------ */
@media (max-width: 640px) {
  .topnav { flex-direction: column; height: auto; padding: 10px 16px; gap: 8px; }
  .page-wrap { padding: 14px 12px; }
  .filter-form { flex-direction: column; }
}
