:root {
:  --iam-primary: #4f46e5;
:  --iam-bg: #f8fafc;
:  --iam-sidebar: #0f172a;
:  --iam-border: rgba(226, 232, 240, 0.9);
:  --iam-muted: #64748b;
:  --iam-danger: #ef4444;
:}

/* Safety: JS toggles `.hidden` in multiple places. */
.hidden {
  display: none !important;
}

/* ---------- App Shell (Admin Console) ---------- */
#appView {
  min-height: 100vh;
  display: flex;
  background: var(--iam-bg);
}

#appView .side {
  width: 18rem; /* w-72 */
  background: var(--iam-sidebar);
  color: rgba(226, 232, 240, 0.88);
  border-right: 1px solid rgba(30, 41, 59, 0.9);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

#appView .brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 24px 24px 10px;
}

#appView .logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--iam-primary);
  box-shadow: 0 14px 26px rgba(79, 70, 229, 0.28);
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
}

#appView .logo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  -webkit-mask: url('/assets/chamii-logo-icon-only.png') center / 72% no-repeat;
  mask: url('/assets/chamii-logo-icon-only.png') center / 72% no-repeat;
  opacity: 0.98;
}

#appView .brandTitle {
  color: #fff;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 18px;
  line-height: 1.1;
}

#appView .brandSub {
  margin-top: 4px;
  font-size: 12px;
  color: rgba(148, 163, 184, 0.92);
  font-weight: 600;
}

#appView .mono {
  font-family:
    'JetBrains Mono',
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    'Liberation Mono',
    'Courier New',
    monospace;
}

#appView .pill {
  margin: 6px 16px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid rgba(51, 65, 85, 0.55);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 12px;
  color: rgba(226, 232, 240, 0.9);
}

#appView .dot {
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  background: #94a3b8;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.35);
}

#appView .dot.ok {
  background: #22c55e;
}

#appView .dot.bad {
  background: var(--iam-danger);
}

#appView .nav {
  margin-top: 16px;
  padding: 16px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
}

#appView .nav button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(148, 163, 184, 0.95);
  font-weight: 700;
  font-size: 13px;
  transition: background-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

#appView .nav button:hover {
  background: rgba(30, 41, 59, 0.9);
  color: #fff;
}

#appView .nav button.active {
  background: var(--iam-primary);
  color: #fff;
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.24);
}

#appView .navIcon {
  width: 18px;
  height: 18px;
  color: rgba(100, 116, 139, 0.95);
}

#appView .nav button:hover .navIcon,
#appView .nav button.active .navIcon {
  color: rgba(255, 255, 255, 0.92);
}

#appView .btnRow,
dialog .btnRow {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

#appView .btnRow button,
#appView .nav button,
#appView button.primary,
#appView button.secondary,
#appView button.danger,
#appView button#btnRefresh,
dialog button {
  -webkit-tap-highlight-color: transparent;
}

#appView button.primary,
#appView button.secondary,
#appView button.danger,
#appView #btnRefresh,
#appView .btnRow button:not(.active),
dialog button.primary,
dialog button.secondary,
dialog button.danger,
dialog .btnRow button {
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.01em;
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

#appView button.primary,
dialog button.primary {
  background: var(--iam-primary);
  color: #fff;
  border-color: rgba(79, 70, 229, 0.7);
  box-shadow: 0 10px 18px rgba(79, 70, 229, 0.18);
}

#appView button.primary:hover,
dialog button.primary:hover {
  background: #4338ca;
}

#appView button.secondary,
#appView #btnRefresh,
dialog button.secondary {
  background: #fff;
  color: rgba(15, 23, 42, 0.8);
}

#appView button.secondary:hover,
#appView #btnRefresh:hover,
dialog button.secondary:hover {
  background: rgba(248, 250, 252, 1);
  border-color: rgba(203, 213, 225, 0.9);
}

#appView button.danger,
dialog button.danger {
  background: rgba(254, 242, 242, 1);
  color: #b91c1c;
  border-color: rgba(254, 202, 202, 0.9);
}

#appView button.danger:hover,
dialog button.danger:hover {
  background: rgba(254, 226, 226, 1);
  border-color: rgba(252, 165, 165, 0.9);
}

#appView button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#appView .btnRow .danger {
  border-color: rgba(252, 165, 165, 0.9);
}

#appView .main {
  flex: 1 1 auto;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--iam-bg);
}

#appView .appHeader {
  height: 72px;
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

#appView .appHeaderLeft h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: rgba(15, 23, 42, 0.92);
}

#appView .appHeaderLeft .sub {
  margin-top: 6px;
  color: var(--iam-muted);
  font-size: 12px;
  font-weight: 600;
}

#appView .appHeaderRight {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#appView .search {
  position: relative;
  min-width: 260px;
  flex: 1 1 260px;
}

#appView .search input {
  width: 100%;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(248, 250, 252, 1);
  padding: 0 12px 0 38px;
  outline: none;
  font-weight: 650;
  color: rgba(15, 23, 42, 0.92);
  transition: box-shadow 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

#appView .search input:focus {
  border-color: rgba(99, 102, 241, 0.7);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
  background: #fff;
}

#appView .searchIcon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: rgba(100, 116, 139, 0.9);
  pointer-events: none;
}

#appView .mainInner {
  padding: 28px 32px 54px;
  max-width: 1280px;
  margin: 0 auto;
}

/* ---------- Content Components ---------- */
#appView .card {
  background: #fff;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

#appView .card:hover {
  border-color: rgba(199, 210, 254, 0.9);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

#appView .cardPad {
  padding: 18px;
}

#appView .grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 1100px) {
  #appView .grid2 {
    grid-template-columns: 1fr;
  }
  #appView .search {
    min-width: 220px;
    flex-basis: 220px;
  }
}

@media (max-width: 980px) {
  #appView {
    display: block;
  }
  #appView .side {
    position: relative;
    height: auto;
    width: auto;
  }
  #appView .main {
    height: auto;
  }
  #appView .appHeader {
    position: relative;
  }
}

#appView .row,
dialog .row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
}

@media (max-width: 560px) {
  #appView .row,
  dialog .row {
    grid-template-columns: 1fr;
  }
}

#appView label,
dialog label {
  font-weight: 800;
  font-size: 12px;
  color: rgba(15, 23, 42, 0.72);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#appView input,
#appView select,
#appView textarea,
dialog input,
dialog select,
dialog textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(248, 250, 252, 1);
  padding: 10px 12px;
  outline: none;
  font-weight: 650;
  color: rgba(15, 23, 42, 0.92);
  transition: box-shadow 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

#appView textarea,
dialog textarea {
  min-height: 96px;
  resize: vertical;
}

#appView input:focus,
#appView select:focus,
#appView textarea:focus,
dialog input:focus,
dialog select:focus,
dialog textarea:focus {
  border-color: rgba(99, 102, 241, 0.7);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
  background: #fff;
}

#appView .sub {
  color: rgba(100, 116, 139, 0.92);
  font-size: 12px;
  font-weight: 650;
}

#appView .small {
  color: rgba(100, 116, 139, 0.92);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
}

/* ---------- Tables ---------- */
#appView .table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  margin-top: 14px;
}

#appView .table th,
#appView .table td {
  text-align: left;
  padding: 12px 14px;
  font-size: 13px;
  vertical-align: top;
}

#appView .table th {
  background: rgba(248, 250, 252, 1);
  color: rgba(100, 116, 139, 0.9);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 11px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.95);
}

#appView .table tr {
  background: #fff;
}

#appView .table tr + tr td {
  border-top: 1px solid rgba(226, 232, 240, 0.6);
}

#appView .table tr:hover {
  background: rgba(248, 250, 252, 0.8);
}

/* ---------- Dialogs ---------- */
dialog {
  width: min(900px, calc(100vw - 32px));
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 18px;
  padding: 0;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
}

.dlgHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(248, 250, 252, 1);
}

.dlgTitle {
  margin: 0;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: -0.01em;
  color: rgba(15, 23, 42, 0.9);
}

.dlgBody {
  padding: 18px;
}

/* ---------- Login Field Effects (Admin Login view uses these via JS) ---------- */
.fieldError {
  border-color: rgba(244, 63, 94, 0.9) !important;
  box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.16) !important;
}

@keyframes fieldShake {
  10%,
  90% {
    transform: translate3d(-1px, 0, 0);
  }
  20%,
  80% {
    transform: translate3d(2px, 0, 0);
  }
  30%,
  50%,
  70% {
    transform: translate3d(-4px, 0, 0);
  }
  40%,
  60% {
    transform: translate3d(4px, 0, 0);
  }
}

.fieldShake {
  animation: fieldShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.err {
  color: var(--iam-danger);
  font-weight: 800;
}

/* Optional shared animation used across login pages. */
.animate-enter {
  animation: enter 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
