:root {
  --primary: #0f5132;
  --primary-dark: #093822;
  --primary-light: #e8f5ee;
  --accent: #d97706;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --border: #d8dee4;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.app-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
}

.header-brand h1 {
  font-size: 16px;
  font-weight: 700;
}
.header-brand p {
  font-size: 12px;
  opacity: 0.9;
}

.header-controls,
.inline-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.header-controls .control-group,
.inline-controls .control-group {
  margin-bottom: 0;
}
.control-group label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.88;
}

select,
input[type="text"],
input[type="password"],
textarea {
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

.btn {
  padding: 8px 13px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-secondary {
  background: var(--primary);
  color: #fff;
}

.app-header .btn-outline {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}
.card .btn-outline {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.main-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.nav-tab {
  padding: 12px 14px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.container {
  max-width: 1400px;
  margin: 16px auto;
  padding: 0 14px 36px;
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 {
  font-size: 16px;
  color: var(--primary-dark);
}
.subtitle {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.kpi-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.kpi-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}
.kpi-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
}
.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
}
.kpi-card.warn {
  background: #fffbeb;
  border-color: #fde68a;
}
.kpi-card.warn .kpi-value {
  color: #b45309;
}

.rotation-banner,
.area-pic-box {
  background: var(--primary-light);
  border: 1px solid #b7e4c7;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.legend-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 12px;
}
.badge {
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid var(--border);
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 14px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table th,
.data-table td {
  border: 1px solid var(--border);
  padding: 5px 6px;
  text-align: center;
}
.data-table th {
  background: #f1f5f9;
  color: #334155;
}

.sticky-col {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 2;
  text-align: left !important;
  min-width: 170px;
}
th.sticky-col {
  background: #f1f5f9;
  z-index: 3;
}

.col-sunday {
  background: #fef2f2 !important;
  color: #b91c1c;
}
.col-friday {
  background: #ecfdf5 !important;
  color: #047857;
}

.imam-cell {
  cursor: pointer;
  font-weight: 700;
  min-width: 30px;
  user-select: none;
}
.status-hadir {
  background: #dcfce7 !important;
  color: #166534 !important;
}
.status-badal {
  background: #dbeafe !important;
  color: #1e40af !important;
}
.status-libur {
  background: #fef3c7 !important;
  color: #92400e !important;
}
.status-izin {
  background: #fee2e2 !important;
  color: #991b1b !important;
}

.note-input {
  width: 100%;
  min-width: 130px;
  border: none;
  background: transparent;
  font-size: 11.5px;
  padding: 3px;
}
.task-name-cell {
  text-align: left !important;
  min-width: 220px;
}

.chk-cell {
  width: 28px;
  min-width: 28px;
  padding: 3px !important;
  cursor: pointer;
}
.chk-box {
  width: 17px;
  height: 17px;
  border: 1.5px solid #94a3b8;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: transparent;
}
.chk-box.checked {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.notes-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 12.5px;
}
.notes-box ol,
.notes-box ul {
  padding-left: 18px;
  margin-top: 6px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}
.add-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.add-form input[type="text"],
.add-form input[type="password"] {
  flex: 1;
  min-width: 140px;
}

.person-list,
.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.person-list li,
.history-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12.5px;
}

.contact-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}
.contact-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.role-imam-mode .marbot-only-tab {
  display: none;
}
.role-marbot-mode .imam-only-tab {
  display: none;
}
.role-restricted .pengurus-only {
  display: none !important;
}

@media print {
  .no-print {
    display: none !important;
  }
  body {
    background: #fff;
    font-size: 10px;
  }
  .card {
    border: none;
    padding: 0;
  }
  @page {
    size: landscape;
    margin: 8mm;
  }
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}
.btn-danger:hover {
  background: #b91c1c;
}
