/* St. Antony's ERP — mobile first */
:root {
  --blue: #1f4e79; --blue-2: #2f6aa3; --bg: #f4f6f9; --card: #fff; --text: #1d2733; --muted: #5d6b7a;
  --line: #d9e0e8; --red: #b3261e; --green: #1e7d3a; --amber: #8a5a00; --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Telugu", sans-serif;
  color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; font-size: 16px; line-height: 1.45; }
a { color: var(--blue-2); }
h1 { font-size: 1.3rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.loading, .empty { color: var(--muted); padding: 1rem 0; }
[hidden] { display: none !important; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; min-height: 44px; padding: .5rem 1rem;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); font: inherit; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--blue-2); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-quiet { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.btn-block { width: 100%; }
.icon-btn { min-width: 44px; min-height: 44px; border: 0; background: transparent; font-size: 1.3rem; cursor: pointer; color: inherit; }
:focus-visible { outline: 3px solid #f2b705; outline-offset: 2px; }

/* top bar + menu */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .5rem; padding: .25rem .5rem;
  background: var(--blue); color: #fff; padding-top: max(.25rem, env(safe-area-inset-top)); }
.brand { color: #fff; font-weight: 700; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; gap: .4rem; }
.sync-btn { min-height: 38px; padding: .3rem .7rem; }
.sync-warn { background: #fff4d6; color: var(--amber); }
.shell { display: block; }
.sidebar { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: 260px; transform: translateX(-100%); transition: transform .2s;
  background: #fff; border-right: 1px solid var(--line); padding: 1rem; overflow-y: auto; }
body.nav-open .sidebar { transform: none; }
.nav-backdrop { display: none; }
body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.35); }
.who { display: flex; flex-direction: column; padding-bottom: .75rem; margin-bottom: .5rem; border-bottom: 1px solid var(--line); }
.who small { color: var(--muted); }
.nav { display: flex; flex-direction: column; }
.nav a { padding: .75rem .5rem; border-radius: 8px; text-decoration: none; color: var(--text); }
.nav a.active { background: #e7eef6; color: var(--blue); font-weight: 600; }
.page { padding: 1rem; max-width: 1100px; margin: 0 auto; outline: none; }

@media (min-width: 900px) {
  .menu-btn { display: none; }
  .shell { display: grid; grid-template-columns: 240px 1fr; }
  .sidebar { position: sticky; top: 52px; height: calc(100vh - 52px); transform: none; width: auto; }
  .nav-backdrop { display: none !important; }
}

/* page parts */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; justify-content: space-between; margin-bottom: 1rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.notice { background: #fff8e1; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.tile { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; text-decoration: none; color: var(--text); }
.tile-value { font-size: 1.8rem; font-weight: 700; color: var(--blue); }
.tile-label { color: var(--muted); }
.filters { display: grid; grid-template-columns: 1fr; gap: .5rem; margin-bottom: .5rem; }
@media (min-width: 700px) { .filters { grid-template-columns: 1fr 1fr 2fr; } }

/* badges */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; background: #e7eef6; color: var(--blue); white-space: nowrap; }
.badge-active { background: #e3f4e8; color: var(--green); }
.badge-left { background: #eceff1; color: #455a64; }
.badge-non_attending { background: #fff4d6; color: var(--amber); }
.badge-pending { background: #fff4d6; color: var(--amber); }
.badge-disabled { background: #fde7e6; color: var(--red); }

/* forms */
input, select, textarea { width: 100%; min-height: 44px; padding: .5rem .6rem; border: 1px solid #b9c4d0; border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
input:disabled, select:disabled, textarea:disabled { background: #f1f3f6; color: var(--text); }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; }
.field label { font-weight: 600; font-size: .92rem; }
.field .hint { color: var(--muted); }
.field .error, .error, .form-message { color: var(--red); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }
.form-section { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin: 0 0 1rem; padding: .75rem 1rem 0; }
.form-section legend { font-weight: 700; padding: 0 .4rem; color: var(--blue); }
.grid { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
@media (min-width: 700px) { .grid { grid-template-columns: 1fr 1fr; } }
.form-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 0;
  background: linear-gradient(transparent, var(--bg) 30%); }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { margin-bottom: .25rem; color: var(--blue); }

/* tables: real table on wide screens, cards on phones */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); }
.data-table th { background: #eef2f6; font-size: .85rem; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover { background: #f5f8fb; }
.data-table .num { text-align: right; }
@media (max-width: 699px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .6rem; padding: .4rem .2rem; background: #fff; }
  .data-table td { border: 0; padding: .2rem .6rem; display: flex; justify-content: space-between; gap: 1rem; }
  .data-table td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; }
  .data-table .num { text-align: left; }
}

/* pop-ups and messages */
.modal { width: min(560px, calc(100vw - 1.5rem)); max-height: calc(100vh - 2rem); border: 0; border-radius: var(--radius); padding: 0; }
.modal::backdrop { background: rgba(0,0,0,.4); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: .5rem .5rem .5rem 1rem; border-bottom: 1px solid var(--line); }
.modal-body { padding: 1rem; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1rem; border-top: 1px solid var(--line); }
.toasts { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .5rem; width: min(480px, calc(100vw - 2rem)); }
.toast { background: #263238; color: #fff; padding: .75rem 1rem; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.toast-error { background: var(--red); }
.failed-item { border-top: 1px solid var(--line); padding: .5rem 0; }
.status-card p { margin: .5rem 0 0; }
