/* =====================================================================
   RPIIT ACADEMICS ERP — stylesheet
   No frameworks, no CDN. One file, works offline.
   ===================================================================== */

:root {
  --bg:        #f4f6f9;
  --surface:   #ffffff;
  --border:    #e2e8f0;
  --border-2:  #cbd5e1;
  --text:      #16202c;
  --muted:     #64748b;
  --faint:     #94a3b8;

  --brand:     #1f4e79;
  --brand-600: #1a4269;
  --brand-100: #e8eff6;

  --ok:        #15803d;
  --ok-bg:     #ecfdf3;
  --warn:      #b45309;
  --warn-bg:   #fffbeb;
  --bad:       #b91c1c;
  --bad-bg:    #fef2f2;
  --info:      #0369a1;
  --info-bg:   #f0f9ff;

  --radius:    8px;
  --radius-sm: 5px;
  --shadow:    0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  --shadow-lg: 0 4px 6px -1px rgba(15,23,42,.08), 0 10px 24px -6px rgba(15,23,42,.14);
  --sidebar-w: 236px;
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .98rem; }

/* ---------------------------------------------------------------- layout */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--brand);
  color: #dbe7f2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 1rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand .name { color: #fff; font-weight: 650; font-size: 1rem; display: block; }
.sidebar-brand .sub  { font-size: .72rem; color: rgba(255,255,255,.6); letter-spacing: .02em; }

.nav { padding: .5rem 0 2rem; }
.nav-section {
  padding: .9rem 1.1rem .3rem;
  font-size: .67rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: rgba(255,255,255,.45);
  font-weight: 600;
}
.nav a {
  display: block;
  padding: .48rem 1.1rem;
  color: #dbe7f2;
  font-size: .875rem;
  border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav a.active {
  background: rgba(255,255,255,.13);
  border-left-color: #fff;
  color: #fff;
  font-weight: 550;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .7rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .page-title { font-size: 1.02rem; font-weight: 600; margin: 0; }
.topbar .spacer { flex: 1; }
.topbar .year-chip {
  background: var(--brand-100);
  color: var(--brand);
  padding: .22rem .6rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 550;
}
.topbar .user {
  display: flex; align-items: center; gap: .55rem;
  font-size: .85rem;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center;
  font-size: .72rem; font-weight: 650;
}

.content { padding: 1.3rem 1.4rem 3rem; max-width: 1500px; width: 100%; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.1rem;
}
.card-head {
  padding: .8rem 1.1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { flex: 1; }
.card-body { padding: 1.1rem; }
.card-body.tight { padding: .7rem 1.1rem; }
.card-foot {
  padding: .7rem 1.1rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  border-radius: 0 0 var(--radius) var(--radius);
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
}

.hint { color: var(--muted); font-size: .82rem; margin: .3rem 0 0; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.mono  { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }

/* ---------------------------------------------------------------- stats */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: .9rem;
  margin-bottom: 1.2rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .95rem 1.1rem;
  box-shadow: var(--shadow);
  display: block;
  color: inherit;
}
.stat:hover { text-decoration: none; border-color: var(--border-2); box-shadow: var(--shadow-lg); }
.stat .value { font-size: 1.75rem; font-weight: 650; line-height: 1.1; color: var(--brand); }
.stat .label { color: var(--muted); font-size: .82rem; margin-top: .15rem; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .87rem;
}
table.data th {
  text-align: left;
  padding: .6rem .8rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  white-space: nowrap;
}
table.data td {
  padding: .62rem .8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:hover { background: #fbfcfe; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data .primary-cell { font-weight: 550; }

.empty {
  padding: 2.6rem 1.2rem;
  text-align: center;
  color: var(--muted);
}
.empty .big { font-size: 1rem; font-weight: 550; color: var(--text); margin-bottom: .3rem; }

/* ---------------------------------------------------------------- forms */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: .9rem 1.1rem;
}
.field { display: flex; flex-direction: column; gap: .28rem; min-width: 0; }
.field.full { grid-column: 1 / -1; }

label { font-size: .82rem; font-weight: 550; color: #334155; }
label .req { color: var(--bad); }

input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=time], input[type=search], input[type=file],
select, textarea {
  width: 100%;
  padding: .48rem .6rem;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31,78,121,.12);
}
input:disabled, select:disabled { background: #f1f5f9; color: var(--muted); }
textarea { min-height: 74px; resize: vertical; }
select { cursor: pointer; }

.field-help { font-size: .76rem; color: var(--muted); }
.field-error { font-size: .78rem; color: var(--bad); font-weight: 500; }
.field.has-error input, .field.has-error select { border-color: var(--bad); }

.check { display: flex; align-items: flex-start; gap: .45rem; font-weight: 400; }
.check input { width: auto; margin-top: .18rem; }

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem 1rem;
  margin: 0 0 1rem;
}
legend { font-size: .8rem; font-weight: 600; color: var(--brand); padding: 0 .4rem; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .46rem .85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: #fff;
  color: var(--text);
  font-size: .855rem;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.35;
}
.btn:hover { background: #f8fafc; text-decoration: none; border-color: #94a3b8; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }

.btn-danger { background: #fff; border-color: #fca5a5; color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); }

.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn-row { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* ---------------------------------------------------------------- pills */

.pill {
  display: inline-block;
  padding: .13rem .5rem;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}
.pill-ok   { background: var(--ok-bg);   color: var(--ok);   }
.pill-bad  { background: var(--bad-bg);  color: var(--bad);  }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-off  { background: #f1f5f9;        color: var(--muted);}

/* ---------------------------------------------------------------- alerts */

.alert {
  padding: .7rem .95rem;
  border-radius: var(--radius-sm);
  border: 1px solid;
  margin-bottom: .85rem;
  font-size: .87rem;
}
.alert-success { background: var(--ok-bg);   border-color: #a7f3d0; color: #14532d; }
.alert-danger  { background: var(--bad-bg);  border-color: #fecaca; color: #7f1d1d; }
.alert-warning { background: var(--warn-bg); border-color: #fde68a; color: #78350f; }
.alert-info    { background: var(--info-bg); border-color: #bae6fd; color: #0c4a6e; }
.alert ul { margin: .4rem 0 0; padding-left: 1.1rem; }

/* ---------------------------------------------------------------- filters */

.filters {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filters .field { min-width: 155px; flex: 0 1 auto; }
.filters .grow { flex: 1 1 220px; }

/* ---------------------------------------------------------------- pagination */

.pager {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
}
.pager a, .pager span {
  padding: .32rem .6rem;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  font-size: .82rem;
  background: #fff;
  color: var(--text);
}
.pager a:hover { background: #f1f5f9; text-decoration: none; }
.pager .current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pager .disabled { opacity: .45; }

/* ---------------------------------------------------------------- auth pages */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, #1f4e79 0%, #0f2942 100%);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 11px;
  box-shadow: 0 20px 50px rgba(0,0,0,.28);
  padding: 1.9rem;
}
.auth-card.wide { max-width: 720px; }
.auth-head { text-align: center; margin-bottom: 1.3rem; }
.auth-head .logo {
  width: 52px; height: 52px; border-radius: 12px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 1.15rem;
  margin: 0 auto .7rem;
}
.auth-head h1 { font-size: 1.2rem; margin-bottom: .15rem; }
.auth-head p { color: var(--muted); font-size: .85rem; margin: 0; }

/* ---------------------------------------------------------------- misc */

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li {
  display: flex; align-items: center; gap: .6rem;
  padding: .52rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .87rem;
}
.checklist li:last-child { border-bottom: none; }
.checklist .mark {
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: .7rem; font-weight: 700; flex: 0 0 20px;
}
.checklist .mark.done    { background: var(--ok-bg);  color: var(--ok); }
.checklist .mark.pending { background: #f1f5f9;       color: var(--faint); }
.checklist .grow { flex: 1; }

.breadcrumb {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: .7rem;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb .sep { margin: 0 .35rem; color: var(--faint); }

.kv { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: .5rem .9rem; font-size: .87rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.matrix { width: 100%; border-collapse: collapse; font-size: .84rem; }
.matrix th, .matrix td { padding: .42rem .55rem; border: 1px solid var(--border); text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; font-weight: 550; white-space: nowrap; }
.matrix thead th { background: #f8fafc; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.matrix tbody tr:hover { background: #fbfcfe; }
.matrix input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }

.row-error     { background: var(--bad-bg)  !important; }
.row-duplicate { background: var(--warn-bg) !important; }
.row-imported  { background: var(--ok-bg)   !important; }

.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a {
  padding: .5rem .85rem;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: .87rem;
  font-weight: 550;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

.error-page { min-height: 70vh; display: grid; place-items: center; text-align: center; padding: 2rem; }
.error-page .code { font-size: 3.2rem; font-weight: 700; color: var(--brand); line-height: 1; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
  }
  .sidebar .nav { display: none; }
  .sidebar.open .nav { display: block; }
  .content { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: .1rem .5rem; }
  .kv dt { margin-top: .5rem; }
}

@media print {
  .sidebar, .topbar, .btn, .filters, .pager, .card-foot { display: none !important; }
  .content { padding: 0; }
  .card { border: none; box-shadow: none; }
  body { background: #fff; }
}
