:root {
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #0c3f8f;
  --secondary: #0b5d4a;
  --border: #d1d5db;
  --panel: rgba(247, 249, 252, 0.95);
}

* { box-sizing: border-box; }

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background: #10233d;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(10, 26, 49, 0.72), rgba(10, 26, 49, 0.72)), url("assets/bg.jpg");
  background-size: cover, cover;
  background-position: center;
  z-index: -1;
}

body[data-page="login"] {
  background: #e9f0fb;
}

body[data-page="login"]::before {
  background-image:
    radial-gradient(circle at 12% 10%, rgba(255,255,255,0.95), rgba(255,255,255,0.6) 55%, rgba(233,240,251,0.92) 100%),
    radial-gradient(circle at 12% 18%, rgba(12,63,143,0.08) 0 1px, transparent 1px 12px),
    url("assets/bg.jpg");
  background-size: cover, 14px 14px, cover;
  background-position: center, 0 0, center;
  filter: saturate(1.05);
}

.govBanner {
  background: #123b91;
  border-bottom: 1px solid rgba(255,255,255,0.25);
}

.govBanner::after {
  content: "";
  display: block;
  height: 4px;
  background: #f2b705;
}

.govBanner img {
  width: 100%;
  display: block;
  max-height: 160px;
  object-fit: contain;
}

.appHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(245, 247, 250, 0.96);
  border-bottom: 1px solid #dbe3ef;
}

body[data-page="login"] .appHeader {
  display: none;
}

.appHeader h1 {
  margin: 0;
  font-size: 2rem;
}

.appHeader p {
  margin: 4px 0 0;
  color: var(--muted);
}

.topActions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.page {
  padding: 12px;
  display: grid;
  gap: 12px;
  max-width: 100%;
}

body[data-page="login"] .page {
  justify-items: center;
  padding-top: 22px;
  padding-bottom: 70px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(16, 35, 61, 0.15);
  max-width: 100%;
  backdrop-filter: blur(3px);
}

.loginPanel {
  max-width: 980px;
  width: min(980px, 100%);
  padding: 0;
}

h2 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

body[data-page="login"] #loginSection.panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.loginShell {
  width: 100%;
  display: grid;
  gap: 18px;
}

.loginTitle {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 6px;
  color: #0b2c60;
}

.loginTitleIcon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(12, 63, 143, 0.12);
  border: 1px solid rgba(12, 63, 143, 0.18);
}

.loginTitleIcon svg {
  width: 28px;
  height: 28px;
  color: #0c3f8f;
}

.loginTitle h2 {
  margin: 0;
  font-size: 1.85rem;
  letter-spacing: 0.3px;
}

.loginTitle p {
  margin: 2px 0 0;
  color: #64748b;
}

.loginCard {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 12px;
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(8px);
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  overflow: hidden;
}

.loginDivider {
  background: rgba(148, 163, 184, 0.35);
}

.loginCol {
  padding: 18px 18px 16px;
}

.loginColHead {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.loginColIcon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(12, 63, 143, 0.08);
  border: 1px solid rgba(12, 63, 143, 0.16);
  color: #0c3f8f;
}

.loginCol:nth-child(3) .loginColIcon {
  background: rgba(11, 93, 74, 0.08);
  border-color: rgba(11, 93, 74, 0.16);
  color: #0b5d4a;
}

.loginColIcon svg {
  width: 26px;
  height: 26px;
}

.loginCol h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  color: #0b2c60;
}

.loginCol .hint {
  margin: 0;
  line-height: 1.35;
  font-size: 0.9rem;
}

.loginForm {
  margin-top: 8px;
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 4px;
}

.field > span {
  font-size: 0.9rem;
  color: #0f172a;
}

.inputIcon {
  padding-right: 38px;
  height: 40px;
  background-color: #fff;
  background-repeat: no-repeat !important;
  background-size: 18px 18px !important;
  background-position: right 12px center !important;
}

.inputIcon.user {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M20 21c0-3.314-3.582-6-8-6s-8 2.686-8 6' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round'/%3E%3Cpath d='M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8Z' stroke='%236b7280' stroke-width='1.8'/%3E%3C/svg%3E");
}

.inputIcon.lock {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M7 11V8a5 5 0 0 1 10 0v3' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round'/%3E%3Cpath d='M6 11h12v10H6z' stroke='%236b7280' stroke-width='1.8' stroke-linejoin='round'/%3E%3Cpath d='M12 15v3' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}

.inputIcon.id {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M4 7a3 3 0 0 1 3-3h10a3 3 0 0 1 3 3v10a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3V7Z' stroke='%236b7280' stroke-width='1.8'/%3E%3Cpath d='M8 9h8M8 13h5' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}

.inputIcon.school {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M4 10l8-5 8 5' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M6 10v10h12V10' stroke='%236b7280' stroke-width='1.8' stroke-linejoin='round'/%3E%3Cpath d='M9 20v-6h6v6' stroke='%236b7280' stroke-width='1.8' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.loginBtn {
  height: 42px;
  border-radius: 10px;
  color: #fff;
  font-weight: 600;
}

.adminBtn {
  background: linear-gradient(180deg, #0f4aa8, #0c3f8f);
}

.schoolBtn {
  background: linear-gradient(180deg, #0f6a52, #0b5d4a);
}

.loginActions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 2px 0 0;
}

.loginReminder {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(8px);
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
}

.reminderIcon {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(12, 63, 143, 0.12);
  border: 1px solid rgba(12, 63, 143, 0.18);
  color: #0c3f8f;
}

.reminderIcon svg {
  width: 22px;
  height: 22px;
}

.reminderTitle {
  font-weight: 700;
  color: #0c3f8f;
  margin-bottom: 2px;
}

.formGrid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

label {
  display: grid;
  gap: 4px;
  font-size: 0.9rem;
}

input, button {
  font: inherit;
}

input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
}

input[readonly] {
  background: #f3f4f6;
  color: #4b5563;
}

input:focus {
  outline: none;
  border-color: rgba(12, 63, 143, 0.65);
  box-shadow: 0 0 0 3px rgba(12, 63, 143, 0.15);
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  transition: transform 0.05s ease, filter 0.15s ease;
}

.btn.primary { background: var(--primary); color: #fff; }
.btn.secondary { background: var(--secondary); color: #fff; }
.btn.ghost { background: #eef2f7; color: #1f2937; border: 1px solid #d7dee8; }
.btn.danger { background: #c62828; color: #fff; }

.btn:hover { filter: brightness(0.98); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.65; cursor: not-allowed; }

body[data-page="login"] .loginPanel .btn {
  width: 100%;
}

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: #eaf3ff;
  border: 1px solid #bdd7ff;
  font-size: 0.85rem;
}

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

#toolsPanel #searchInput {
  min-width: 260px;
  width: 320px;
}

.panelHead {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.panelHeadActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.panelHeadActions input[type="search"] {
  min-width: 280px;
  width: 320px;
  flex: 0 0 auto;
}

#deleteAllInventoryBtn {
  display: inline-block !important;
  flex: 0 0 auto;
}

.stats {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stat {
  background: #eef4fb;
  border: 1px solid #cad9ee;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.84rem;
}

#message.error {
  color: #991b1b;
  border-color: #fecaca;
  background: #fff1f2;
}

.tableWrap {
  width: 100%;
  max-width: 100%;
  overflow-x: scroll;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: #7ea2d7 #dbe5f3;
}

.hScroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  height: 16px;
  margin-top: 6px;
  scrollbar-width: thin;
  scrollbar-color: #5f89c8 #dbe5f3;
}

.hScroll > div {
  height: 1px;
}

.hScroll::-webkit-scrollbar {
  height: 12px;
}

.hScroll::-webkit-scrollbar-track {
  background: #dbe5f3;
  border-radius: 999px;
}

.hScroll::-webkit-scrollbar-thumb {
  background: #5f89c8;
  border-radius: 999px;
}

.tableSliderRow {
  display: none;
}

.tableSliderRow input[type="range"] {
  width: min(560px, 100%);
}

.tableWrap::-webkit-scrollbar {
  height: 10px;
}

.tableWrap::-webkit-scrollbar-track {
  background: #dbe5f3;
  border-radius: 999px;
}

.tableWrap::-webkit-scrollbar-thumb {
  background: #7ea2d7;
  border-radius: 999px;
}

.inventoryTable {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
}

.inventoryTable thead th {
  position: sticky;
  top: 0;
  background: #1f6b4f;
  color: #fff;
  border: 1px solid #184f3a;
  padding: 8px 7px;
  font-size: 0.8rem;
  white-space: nowrap;
  min-width: 220px;
}

.inventoryTable td {
  border: 1px solid #c5ced6;
  padding: 7px;
  font-size: 0.8rem;
  background: #f8fafc;
  white-space: nowrap;
  min-width: 220px;
}

.inventoryTable tr:nth-child(even) td {
  background: #f1f5f9;
}

.empty { text-align: center; color: #64748b; }
.hint { color: var(--muted); }
.hidden { display: none !important; }

.appFooter {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #0c3f8f;
  color: rgba(255,255,255,0.92);
  border-top: 1px solid rgba(255,255,255,0.18);
  padding: 12px 10px;
  text-align: center;
  font-size: 0.88rem;
  z-index: 10;
}

@media (max-width: 900px) {
  .appHeader { flex-direction: column; align-items: flex-start; }
  .formGrid2 { grid-template-columns: 1fr; }
  .loginCard { grid-template-columns: 1fr; }
  .loginDivider { display: none; }
  .loginActions { grid-template-columns: 1fr; }
}
