@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #2dd4bf;
  --accent-dim: #14b8a6;
  --danger: #f87171;
  --ok: #4ade80;
  --border: rgba(148, 163, 184, 0.2);
  --radius: 10px;
  --font: 'DM Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(45, 212, 191, 0.12), transparent),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: rgba(15, 23, 42, 0.92);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}
.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { color: var(--accent); text-decoration: none; }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  flex: 1;
}
.nav a {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
}
.nav a:hover { color: var(--accent); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-left: auto;
}
.hostel-switch select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  min-width: 140px;
}
.hostel-pill {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.user-name { font-size: 0.88rem; color: var(--muted); }

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.footer {
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}
.alert-error {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
}
.alert-success {
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.35);
  color: #bbf7d0;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-head h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}
.muted { color: var(--muted); font-size: 0.9rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat {
  background: linear-gradient(145deg, var(--surface), #243447);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.stat .n {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
}
.stat .l { font-size: 0.82rem; color: var(--muted); }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.data th,
table.data td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
table.data th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.data tr:hover td { background: rgba(255,255,255,0.02); }

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
textarea,
select {
  width: 100%;
  max-width: 400px;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}
textarea { min-height: 88px; max-width: 100%; }

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: none;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent-dim);
  color: #0f172a;
}
.btn-primary:hover { filter: brightness(1.08); text-decoration: none; color: #0f172a; }
.btn-danger { background: #b91c1c; color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); }

.row-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.login-wrap {
  min-height: calc(100vh - 2rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
}
.login-card h1 { margin: 0 0 0.5rem; font-size: 1.35rem; }
.login-card .sub { margin: 0 0 1.25rem; color: var(--muted); font-size: 0.92rem; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface2);
  color: var(--muted);
}
.badge-ok { background: rgba(45, 212, 191, 0.2); color: var(--accent); }

/* Student portal: anchor from "Pay online" nav jumps below sticky header */
.portal-pay-online {
  scroll-margin-top: 5rem;
}
.portal-pay-online:target {
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.35);
}

/* Fee ledger: receipts inline on same row as fee (no nested table) */
.ledger-receipt-cell {
  vertical-align: middle;
  min-width: 12rem;
  max-width: 48rem;
  overflow-x: auto;
}
.ledger-receipts-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  align-items: flex-start;
  max-width: 100%;
}
.ledger-receipt-chunk {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 0.25rem 0.45rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  line-height: 1.35;
  max-width: 100%;
}
.ledger-receipt-summary {
  color: var(--muted);
  white-space: nowrap;
}
.ledger-receipt-summary strong {
  color: var(--text);
}
.ledger-receipt-tools {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.4rem;
}
.ledger-receipt-tools details {
  display: inline-block;
}
.ledger-receipt-tools summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.78rem;
  list-style: none;
}
.ledger-receipt-tools summary::-webkit-details-marker {
  display: none;
}
.ledger-receipt-panel {
  margin-top: 0.35rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-width: 12rem;
}
.ledger-receipt-panel label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.ledger-receipt-panel input,
.ledger-receipt-panel textarea {
  width: 100%;
  max-width: 16rem;
  box-sizing: border-box;
}
.ledger-record-pay {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  align-items: center;
  white-space: nowrap;
}
.ledger-record-pay input {
  max-width: 5rem;
}

.data-ledger th,
.data-ledger td {
  font-size: 0.86rem;
  vertical-align: middle;
}
.data-ledger td:first-child {
  white-space: normal;
  max-width: 10rem;
}
.data-ledger th:nth-child(2),
.data-ledger td:nth-child(2) {
  white-space: nowrap;
  max-width: 8rem;
}
.ledger-search-bar label {
  font-size: 0.9rem;
  color: var(--muted);
}

@media (max-width: 720px) {
  .nav { width: 100%; order: 3; }
  .topbar-right { width: 100%; justify-content: flex-start; }
}
