@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --green-950: #063818;
  --green-900: #0a4d22;
  --green-800: #0f6b2e;
  --green-700: #15803d;
  --green-600: #1a9a45;
  --green-500: #22c55e;
  --green-100: #dcfce7;
  --green-50: #f0fdf4;
  --gold-500: #eab308;
  --gold-400: #facc15;
  --gold-300: #fde047;
  --gold-600: #ca8a04;
  --ink: #0f1f14;
  --muted: #5b6b5f;
  --line: rgba(15, 107, 46, 0.12);
  --surface: #ffffff;
  --shadow: 0 8px 24px rgba(6, 56, 24, 0.08);
  --radius: 16px;
  --sidebar: 268px;
  --font: 'Outfit', sans-serif;
  --font-arab: 'Amiri', serif;
  --bottom-nav: 64px;
  --appbar: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: #f3f6f4;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body.nav-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

/* ========== AUTH PAGES ========== */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 10% 10%, rgba(250, 204, 21, 0.18), transparent 50%),
    radial-gradient(ellipse 70% 50% at 90% 80%, rgba(34, 197, 94, 0.22), transparent 45%),
    linear-gradient(145deg, #063818 0%, #0f6b2e 42%, #15803d 70%, #0a4d22 100%);
}

.auth-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(250, 204, 21, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(250, 204, 21, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, black 20%, transparent 75%);
  pointer-events: none;
}

.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.45;
  pointer-events: none;
  animation: float 8s ease-in-out infinite;
}

.auth-orb.one {
  width: 280px;
  height: 280px;
  background: var(--gold-400);
  top: -80px;
  right: -40px;
}

.auth-orb.two {
  width: 220px;
  height: 220px;
  background: var(--green-500);
  bottom: -60px;
  left: -40px;
  animation-delay: -3s;
}

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-18px) scale(1.05); }
}

.auth-shell {
  width: min(440px, 100%);
  position: relative;
  z-index: 1;
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-brand {
  text-align: center;
  margin-bottom: 22px;
  color: #fff;
}

.auth-logo {
  width: 132px;
  height: 132px;
  object-fit: contain;
  border-radius: 50%;
  box-shadow:
    0 0 0 4px rgba(250, 204, 21, 0.35),
    0 18px 40px rgba(0, 0, 0, 0.28);
  background: #fff;
  animation: logoIn 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes logoIn {
  from { opacity: 0; transform: scale(0.7) rotate(-8deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

.auth-brand h1 {
  margin: 14px 0 4px;
  font-size: clamp(1.2rem, 3vw, 1.45rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  max-width: min(100%, 22rem);
  margin-left: auto;
  margin-right: auto;
  padding: 0 8px;
}

.auth-brand p {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.95rem;
  font-weight: 400;
}

.auth-arab {
  font-family: var(--font-arab);
  color: var(--gold-300);
  font-size: 1.25rem;
  margin-top: 4px;
}

.auth-panel {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius);
  padding: 28px 26px 24px;
  box-shadow: var(--shadow);
}

.auth-panel h2 {
  margin: 0 0 4px;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--green-900);
}

.auth-panel .subtitle {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.92rem;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--green-900);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 4px rgba(26, 154, 69, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  width: 100%;
  margin-top: 6px;
  color: #fff;
  background: linear-gradient(135deg, var(--green-700), var(--green-600));
  box-shadow: 0 12px 28px rgba(15, 107, 46, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(15, 107, 46, 0.42);
}

.btn-gold {
  color: var(--green-950);
  background: linear-gradient(135deg, var(--gold-400), var(--gold-500));
  box-shadow: 0 10px 24px rgba(234, 179, 8, 0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--green-800);
  border: 1.5px solid var(--line);
}

.auth-footer {
  margin-top: 18px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-footer a {
  color: var(--green-700);
  font-weight: 700;
}

.auth-footer a:hover {
  color: var(--gold-600);
}

.auth-help {
  margin-top: 20px;
  padding: 14px 14px 12px;
  border-radius: 14px;
  background: var(--green-50);
  border: 1px solid rgba(15, 107, 46, 0.12);
}

.auth-help strong {
  display: block;
  color: var(--green-900);
  font-size: 0.92rem;
  margin-bottom: 6px;
}

.auth-help p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.auth-wa {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 999px;
  background: #f0fdf4;
  border: 1px solid rgba(37, 211, 102, 0.28);
  color: #075e54;
  text-decoration: none;
  box-sizing: border-box;
  transition: background 0.15s, border-color 0.15s;
}

.auth-wa:hover {
  background: #dcfce7;
  border-color: rgba(37, 211, 102, 0.5);
}

.auth-wa:active {
  transform: none;
  background: #bbf7d0;
}

.auth-wa-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #25d366;
  color: #fff;
  flex-shrink: 0;
  line-height: 0;
}

.auth-wa-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.auth-wa-text {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  line-height: 1.2;
}

.auth-wa-text em {
  font-style: normal;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.auth-wa-text strong {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: #064e3b;
  letter-spacing: 0.01em;
}

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  margin-bottom: 16px;
  animation: rise 0.4s ease both;
}

.alert-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.alert-success {
  background: var(--green-50);
  color: var(--green-800);
  border: 1px solid #bbf7d0;
}

/* ========== APP LAYOUT ========== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
  background: #f3f6f4;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background:
    linear-gradient(180deg, var(--green-900) 0%, var(--green-800) 55%, var(--green-950) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: 8px 0 40px rgba(6, 56, 24, 0.15);
  z-index: 20;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 18px;
}

.sidebar-brand img {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.45);
  flex-shrink: 0;
}

.sidebar-brand .meta strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.sidebar-brand .meta span {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.65);
}

.nav-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.45);
  padding: 0 12px 10px;
  font-weight: 600;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 500;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.9;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: translateX(3px);
}

.nav-item.active {
  background: var(--gold-400);
  color: var(--green-950);
  font-weight: 700;
  box-shadow: none;
}

.nav-item.active svg {
  opacity: 1;
}

.sidebar-user {
  margin-top: auto;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user .name {
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.3;
}

.sidebar-user .role {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.6);
  margin: 2px 0 10px;
}

.btn-logout {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.18);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn-logout svg {
  width: 16px !important;
  height: 16px !important;
  max-width: 16px;
  max-height: 16px;
  flex: 0 0 16px;
  display: block;
}

.btn-logout span {
  display: inline-block;
  line-height: 1;
}

.btn-logout:hover {
  background: rgba(185, 28, 28, 0.35);
  border-color: rgba(252, 165, 165, 0.4);
  color: #fecaca;
}

.main {
  min-width: 0;
  padding: 28px 32px 40px;
}

.page-body {
  min-width: 0;
}

.mobile-appbar,
.bottom-nav {
  display: none;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--green-950);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.icon-btn:active {
  background: rgba(15, 107, 46, 0.08);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.82rem;
  border-radius: 999px;
  width: auto;
}

.mobile-list {
  display: none;
}

.desktop-only {
  display: block;
}

.stat .stat-copy {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  animation: rise 0.5s ease both;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: clamp(1.5rem, 2.5vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--green-950);
}

.topbar p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--green-800);
  color: #fff;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 28px;
}

.stat {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 18px 16px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: none;
  animation: rise 0.45s ease both;
}

.stat:nth-child(2) { animation-delay: 0.08s; }
.stat:nth-child(3) { animation-delay: 0.16s; }

.stat::after {
  content: '';
  position: absolute;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  right: -20px;
  top: -20px;
  opacity: 0.12;
}

.stat.green::after { background: var(--green-600); }
.stat.gold::after { background: var(--gold-500); }
.stat.teal::after { background: #0d9488; }

.stat .label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.stat .value {
  margin-top: 8px;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--green-950);
}

.stat .icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}

.stat.green .icon { background: var(--green-100); color: var(--green-700); }
.stat.gold .icon { background: #fef9c3; color: var(--gold-600); }
.stat.teal .icon { background: #ccfbf1; color: #0f766e; }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: none;
  animation: rise 0.45s ease both;
}

.panel-soft {
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 750;
  color: var(--green-900);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.quick-link {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  transition: background 0.2s, border-color 0.2s;
}

.quick-link:hover {
  background: var(--green-50);
  border-color: rgba(26, 154, 69, 0.28);
}

.quick-link > div:last-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.quick-link .qi {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--green-700);
  color: #fff;
}

.quick-link .qi svg {
  width: 20px;
  height: 20px;
}

.quick-link strong {
  font-size: 1.05rem;
  color: var(--green-950);
}

.quick-link span {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  background: var(--green-50);
}

tr:hover td {
  background: rgba(240, 253, 244, 0.5);
}

.badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-aktif,
.badge-hadir { background: var(--green-100); color: var(--green-800); }
.badge-izin { background: #e0f2fe; color: #0369a1; }
.badge-sakit { background: #fef9c3; color: #a16207; }
.badge-alpha { background: #fee2e2; color: #b91c1c; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  align-items: end;
}

.toolbar .form-group {
  margin: 0;
  flex: 1;
  min-width: 140px;
}

.toolbar .btn {
  width: auto;
  margin: 0;
  white-space: nowrap;
}

.import-panel .import-hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.import-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.import-form input[type="file"] {
  flex: 1;
  min-width: 220px;
  padding: 12px 14px;
  border: 1.5px dashed rgba(15, 107, 46, 0.35);
  border-radius: 14px;
  background: var(--green-50);
  cursor: pointer;
}

.import-form input[type="file"]:hover {
  border-color: var(--green-600);
}

.rapor-section-title {
  margin: 22px 0 10px;
  font-size: 1.05rem;
  font-weight: 750;
  color: var(--green-900);
}

.rapor-input-table input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.rapor-input-table th.col-angka,
.rapor-input-table td.col-angka {
  width: 130px;
  min-width: 130px;
}

.rapor-input-table .angka-input {
  width: 100%;
  min-width: 110px;
  padding: 8px 12px;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

.rapor-input-table .locked-field {
  background: #f3f6f4;
  color: #334155;
  cursor: default;
  border-color: #e2e8f0;
  font-weight: 600;
}

.rapor-input-table .angka-input::-webkit-outer-spin-button,
.rapor-input-table .angka-input::-webkit-inner-spin-button {
  opacity: 1;
  margin-left: 4px;
}

.rapor-input-table td {
  vertical-align: middle;
}

textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
  resize: vertical;
  font: inherit;
}

textarea:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 4px rgba(26, 154, 69, 0.15);
}

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

/* ========== KARTU SANTRI ========== */
.kartu-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 18px;
  align-items: start;
}

.kartu-list-panel {
  max-height: calc(100vh - 140px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.kartu-search {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.kartu-search input {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
}

.kartu-santri-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.kartu-santri-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.kartu-santri-item:hover {
  background: var(--green-50);
}

.kartu-santri-item.active {
  background: var(--green-50);
  border-color: rgba(26, 154, 69, 0.3);
}

.kartu-santri-item .thumb {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--green-700), var(--green-500));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
}

.kartu-santri-item .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kartu-santri-item strong {
  display: block;
  font-size: 0.88rem;
  color: var(--green-950);
  line-height: 1.25;
}

.kartu-santri-item small {
  color: var(--muted);
  font-size: 0.75rem;
}

.kartu-actions {
  display: flex;
  gap: 8px;
}

.kartu-print-area {
  display: flex;
  justify-content: center;
  padding: 12px 0 8px;
}

.kartu-santri-card {
  width: min(560px, 100%);
  aspect-ratio: 1.7 / 1;
  padding: 18px 20px 16px;
  border-radius: 22px;
  border: 1px solid rgba(15, 107, 46, 0.18);
  background:
    radial-gradient(ellipse 70% 80% at 8% 0%, rgba(134, 239, 172, 0.55), transparent 55%),
    radial-gradient(ellipse 50% 60% at 100% 100%, rgba(187, 247, 208, 0.35), transparent 50%),
    linear-gradient(145deg, #f0fdf4 0%, #ffffff 48%, #f8fffb 100%);
  box-shadow: 0 16px 40px rgba(6, 56, 24, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kartu-head {
  display: block;
  margin: 0;
  padding: 0;
}

.kartu-kop {
  width: 100%;
  max-height: 72px;
  height: auto;
  object-fit: contain;
  object-position: left center;
  display: block;
  mix-blend-mode: multiply;
}

.kartu-kop-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
}

.kartu-kop-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
}

.kartu-kop-ident {
  min-width: 0;
  flex: 1;
  line-height: 1.2;
}

.kartu-kop-title {
  font-size: 0.78rem;
  font-weight: 800;
  color: #0b3d24;
  text-transform: uppercase;
}

.kartu-kop-sub {
  font-size: 0.68rem;
  font-weight: 700;
  color: #1f4d33;
  text-transform: uppercase;
  margin-top: 1px;
}

.kartu-kop-alamat {
  font-size: 0.62rem;
  color: #445;
  margin-top: 2px;
}

.kartu-divider {
  margin: 8px 0 8px;
  border-bottom: 1.5px dotted rgba(15, 107, 46, 0.35);
}

.kartu-title {
  margin: 0 0 10px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #0b3d24;
}

.kartu-body {
  flex: 1;
  display: grid;
  grid-template-columns: 110px 1fr 110px;
  gap: 14px;
  align-items: start;
  min-height: 0;
}

.kartu-photo {
  width: 110px;
  height: 140px;
  border-radius: 8px;
  overflow: hidden;
  background: #dbeafe;
  border: 1px solid rgba(15, 107, 46, 0.15);
}

.kartu-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.kartu-photo-empty {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8px;
  font-size: 0.72rem;
  color: #64748b;
  background: #e2e8f0;
}

.kartu-info {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.kartu-info > div {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 4px;
  align-items: start;
}

.kartu-info dt {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #0b3d24;
}

.kartu-info dd {
  margin: 0;
  display: grid;
  grid-template-columns: 12px 1fr;
  column-gap: 6px;
  font-size: 0.8rem;
  color: #12261a;
  line-height: 1.35;
}

.kartu-info .kartu-colon {
  flex-shrink: 0;
}

.kartu-info .kartu-val {
  min-width: 0;
  word-break: break-word;
  text-transform: uppercase;
}

.kartu-info > div:first-child .kartu-val {
  font-weight: 800;
  font-size: 0.84rem;
}

.kartu-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 2px;
}

.kartu-qr img {
  width: 108px;
  height: 108px;
  background: #fff;
  border-radius: 6px;
  padding: 4px;
  border: 1px solid rgba(15, 107, 46, 0.12);
}

.kartu-qr span {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #0b3d24;
}

.kartu-upload {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.kartu-upload h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  color: var(--green-900);
}

.kartu-upload p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 56, 24, 0.45);
  z-index: 15;
}

@media print {
  body * { visibility: hidden; }
  .kartu-print-area,
  .kartu-print-area * { visibility: visible; }
  .kartu-print-area {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: #fff;
  }
  .kartu-santri-card {
    box-shadow: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .no-print, .sidebar, .topbar, .overlay, .alert { display: none !important; }
}

/* ========== ANDROID / MOBILE ========== */
@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    min-height: 100dvh;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    width: min(300px, 84vw);
    height: 100dvh;
    padding-top: calc(14px + var(--safe-top));
    padding-bottom: calc(14px + var(--safe-bottom));
    border-radius: 0 20px 20px 0;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.22);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .overlay {
    z-index: 40;
  }

  .overlay.show {
    display: block;
  }

  .sidebar {
    z-index: 50;
  }

  .menu-toggle {
    display: none;
  }

  .mobile-appbar {
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: calc(var(--appbar) + var(--safe-top));
    padding: var(--safe-top) 8px 0;
    margin: -8px -16px 12px;
    padding-left: 8px;
    padding-right: 12px;
    background: rgba(243, 246, 244, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(15, 107, 46, 0.08);
  }

  .mobile-appbar-title {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
  }

  .mobile-appbar-title strong {
    font-size: 1.05rem;
    font-weight: 750;
    color: var(--green-950);
    letter-spacing: -0.02em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-appbar-title span {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-appbar-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: contain;
    background: #fff;
    border: 1.5px solid rgba(15, 107, 46, 0.12);
  }

  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    min-height: calc(var(--bottom-nav) + var(--safe-bottom));
    padding: 6px 4px calc(6px + var(--safe-bottom));
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(15, 107, 46, 0.1);
    box-shadow: 0 -4px 20px rgba(6, 56, 24, 0.06);
  }

  .bn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    padding: 4px 2px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    border-radius: 12px;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }

  .bn-item svg {
    width: 22px;
    height: 22px;
  }

  .bn-item.active {
    color: var(--green-800);
  }

  .bn-item.active svg {
    stroke-width: 2.4;
  }

  .bn-item span {
    line-height: 1;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .main {
    padding: 8px 16px calc(var(--bottom-nav) + var(--safe-bottom) + 20px);
  }

  .topbar {
    display: none;
  }

  .stats {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 14px;
  }

  .stat {
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 14px;
  }

  .stat::after {
    display: none;
  }

  .stat .icon {
    margin: 0;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    flex-shrink: 0;
  }

  .stat .icon svg {
    width: 20px;
    height: 20px;
  }

  .stat .label {
    font-size: 0.78rem;
  }

  .stat .value {
    margin-top: 2px;
    font-size: 1.45rem;
  }

  .quick-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .panel {
    padding: 14px;
    border-radius: 14px;
  }

  .panel-head {
    margin-bottom: 12px;
  }

  .panel-head h2 {
    font-size: 1rem;
  }

  .mobile-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .desktop-only {
    display: none !important;
  }

  .mobile-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 14px;
    background: #f8faf8;
    border: 1px solid transparent;
  }

  .mli-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--green-100);
    color: var(--green-800);
    display: grid;
    place-items: center;
    font-weight: 800;
    flex-shrink: 0;
  }

  .mli-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .mli-body strong {
    font-size: 0.9rem;
    color: var(--green-950);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mli-body span {
    font-size: 0.75rem;
    color: var(--muted);
  }

  .mli-meta {
    font-size: 0.72rem;
    color: var(--muted);
    font-weight: 600;
    max-width: 72px;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Tables → stacked cards when no mobile-list alternative */
  .table-wrap:not(.desktop-only) table:not(.rapor-input-table) thead {
    display: none;
  }

  .table-wrap:not(.desktop-only) table:not(.rapor-input-table),
  .table-wrap:not(.desktop-only) table:not(.rapor-input-table) tbody,
  .table-wrap:not(.desktop-only) table:not(.rapor-input-table) tr,
  .table-wrap:not(.desktop-only) table:not(.rapor-input-table) td {
    display: block;
    width: 100%;
  }

  .table-wrap:not(.desktop-only) table:not(.rapor-input-table) tr {
    margin-bottom: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fafcfb;
  }

  .table-wrap:not(.desktop-only) table:not(.rapor-input-table) td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border: none;
    font-size: 0.88rem;
  }

  .table-wrap:not(.desktop-only) table:not(.rapor-input-table) td::before {
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    flex-shrink: 0;
  }

  .table-wrap:not(.desktop-only) table:not(.rapor-input-table) td:empty::before,
  .table-wrap:not(.desktop-only) table:not(.rapor-input-table) td[data-label=""]::before {
    display: none;
  }

  .table-wrap:not(.desktop-only) table:not(.rapor-input-table) td select,
  .table-wrap:not(.desktop-only) table:not(.rapor-input-table) td input {
    flex: 1;
    min-width: 0;
  }

  .table-wrap:not(.desktop-only) table:not(.rapor-input-table) tr:hover td {
    background: transparent;
  }

  .table-wrap:not(.desktop-only) {
    overflow: visible;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .toolbar form {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar .form-group,
  .toolbar .btn {
    width: 100%;
    min-width: 0;
  }

  .import-form {
    flex-direction: column;
    align-items: stretch;
  }

  .import-form input[type="file"] {
    min-width: 0;
    width: 100%;
  }

  .kartu-layout {
    grid-template-columns: 1fr;
  }

  .kartu-list-panel {
    max-height: 240px;
  }

  .kartu-actions {
    flex-wrap: wrap;
  }

  .kartu-actions .btn {
    flex: 1;
    min-width: 120px;
  }

  .kartu-body {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 12px;
  }

  .kartu-info > div {
    grid-template-columns: 70px 1fr;
    text-align: left;
  }

  .kartu-photo {
    width: 100px;
    height: 128px;
  }

  .kartu-qr img {
    width: 96px;
    height: 96px;
  }

  .auth-page {
    padding: 24px 16px calc(24px + var(--safe-bottom));
    align-items: flex-start;
    padding-top: max(32px, calc(16px + var(--safe-top)));
  }

  .auth-logo {
    width: 96px;
    height: 96px;
  }

  .auth-panel {
    padding: 22px 18px 20px;
    border-radius: 18px;
  }

  .auth-orb {
    opacity: 0.28;
  }

  .empty {
    padding: 28px 12px;
    font-size: 0.9rem;
  }
}

@media (max-width: 980px) and (min-width: 560px) {
  .stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .stat {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 380px) {
  .bn-item span {
    font-size: 0.58rem;
  }

  .mobile-appbar-title strong {
    font-size: 0.95rem;
  }
}
