/* Art direction: clean premium admin dashboard, soft neutral surfaces, teal accent, compact and elegant */

@import url("https://api.fontshare.com/v2/css?f[]=satoshi@400,500,700&display=swap");

:root,
[data-theme="light"] {
  --bg: #f6f4ef;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #fcfbf8;
  --surface-2: #f3f0ea;
  --surface-3: #e9e4dc;
  --text: #201f1b;
  --muted: #6f6b63;
  --faint: #aaa59d;
  --border: rgba(32, 31, 27, 0.09);
  --divider: rgba(32, 31, 27, 0.06);

  --primary: #0f7b83;
  --primary-hover: #0b666d;
  --primary-soft: rgba(15, 123, 131, 0.12);

  --success: #467a2f;
  --warning: #b06a16;
  --danger: #b24468;
  --info: #2f68b8;

  --shadow-sm: 0 1px 2px rgba(17, 16, 14, 0.04);
  --shadow-md: 0 10px 30px rgba(17, 16, 14, 0.07);
  --shadow-lg: 0 20px 60px rgba(17, 16, 14, 0.12);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  --topbar-h: 74px;
  --sidebar-w: 310px;
}

[data-theme="dark"] {
  --bg: #141412;
  --surface: rgba(29, 29, 26, 0.78);
  --surface-solid: #1b1b18;
  --surface-2: #23231f;
  --surface-3: #2d2d28;
  --text: #ece8e1;
  --muted: #a7a198;
  --faint: #7b766d;
  --border: rgba(255, 255, 255, 0.08);
  --divider: rgba(255, 255, 255, 0.06);

  --primary: #58a7af;
  --primary-hover: #6cb7be;
  --primary-soft: rgba(88, 167, 175, 0.16);

  --success: #7db160;
  --warning: #d39b49;
  --danger: #d27a9b;
  --info: #76a9e8;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.42);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Satoshi", "Inter", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, var(--primary-soft), transparent 24%),
    radial-gradient(
      circle at top right,
      rgba(255, 255, 255, 0.28),
      transparent 22%
    ),
    var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  border-radius: var(--radius-md);
  min-height: 46px;
  padding: 0 14px;
  outline: none;
  transition: 0.2s ease;
}

textarea {
  min-height: 96px;
  padding: 12px 14px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

table {
  width: 100%;
  border-collapse: collapse;
}

.app {
  min-height: 100dvh;
  padding: 20px;
}

/* TOPBAR */
.topbar {
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 12px;
  z-index: 40;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.logo svg {
  flex-shrink: 0;
  filter: drop-shadow(0 4px 10px rgba(15, 123, 131, 0.15));
}

.topbar-divider {
  width: 1px;
  height: 26px;
  background: var(--divider);
}

.stats-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stats-inline .stat-chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.icon-btn,
.btn {
  min-height: 44px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: 0.2s ease;
}

.icon-btn:hover,
.btn:hover {
  transform: translateY(-1px);
}

.icon-btn {
  width: 44px;
  min-width: 44px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
}

.btn {
  padding: 0 14px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}

.btn-primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-hover));
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 123, 131, 0.22);
}

.btn-primary:hover {
  filter: brightness(1.03);
}

.btn-ghost {
  background: var(--surface-solid);
  border-color: var(--border);
}

.btn-xs {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
}

/* BODY */
.body-wrap {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(270px, var(--sidebar-w)) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.sidebar,
.main-area,
.export-box,
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.sidebar {
  border-radius: var(--radius-xl);
  padding: 18px;
  position: sticky;
  top: 102px;
}

.sidebar-section {
  padding: 16px;
  background: linear-gradient(180deg, var(--surface-solid), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.sidebar-section + .sidebar-section {
  margin-top: 14px;
}

.sec-label {
  margin-bottom: 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}

.form-group + .form-group {
  margin-top: 12px;
}

.form-group label {
  display: inline-block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.main-area {
  border-radius: var(--radius-xl);
  overflow: hidden;
  min-width: 0;
}

/* TOOLBAR */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--divider);
  background: color-mix(in srgb, var(--surface-solid) 76%, var(--surface-2));
  flex-wrap: wrap;
}

.toolbar-search {
  min-width: 240px;
  flex: 1 1 320px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-solid);
  min-height: 46px;
}

.toolbar-search svg {
  color: var(--muted);
  flex-shrink: 0;
}

.toolbar-search input {
  border: 0;
  min-height: auto;
  padding: 0;
  background: transparent;
  box-shadow: none !important;
}

.toolbar > select {
  width: auto;
  min-width: 170px;
  background: var(--surface-solid);
}

/* TABLE */
.table-area {
  width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--divider);
  padding: 15px 16px;
  white-space: nowrap;
}

table tbody td {
  padding: 15px 16px;
  border-bottom: 1px solid var(--divider);
  vertical-align: top;
}

table tbody tr {
  transition:
    background 0.18s ease,
    transform 0.18s ease;
}

table tbody tr:hover {
  background: var(--primary-soft);
}

.empty-state {
  min-height: 320px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
  padding: 28px;
  color: var(--muted);
}

.empty-state svg {
  width: 44px;
  height: 44px;
  opacity: 0.7;
}

.empty-state h3 {
  margin: 6px 0 0;
  font-size: 20px;
  color: var(--text);
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

/* PAGINATION */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-top: 1px solid var(--divider);
  background: var(--surface-solid);
  flex-wrap: wrap;
}

.pag-left,
.pag-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pag-info {
  color: var(--muted);
  font-size: 13px;
}

.per-page-sel {
  width: auto;
  min-width: 84px;
}

#groupList {
  display: grid;
  gap: 8px;
}

#groupList .group-item,
#pagBtns button {
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#groupList .group-item:hover,
#pagBtns button:hover {
  background: var(--surface-2);
}

/* MODAL / EXPORT */
.export-panel,
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 16, 18, 0.42);
  backdrop-filter: blur(8px);
  z-index: 70;
  padding: 20px;
}

.export-panel,
.modal-overlay {
  display: grid;
  place-items: center;
}

.export-box,
.modal {
  width: min(100%, 560px);
  border-radius: 22px;
  padding: 20px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
}

.export-title,
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.export-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
}

.export-close,
.modal-close {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.export-opt-group + .export-opt-group {
  margin-top: 16px;
}

.export-opt-label {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.fmt-btns,
.status-btns,
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.fmt-btn,
.status-btn,
.export-do {
  min-height: 42px;
  border-radius: 12px;
}

.fmt-btn,
.status-btn {
  padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}

.fmt-btn.sel,
.status-btn.sel {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.export-do {
  width: 100%;
  margin-top: 18px;
  background: linear-gradient(180deg, var(--primary), var(--primary-hover));
  color: #fff;
  font-weight: 700;
}

/* TOAST */
#toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 260px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

/* BADGES */
.badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}

.status-active {
  background: rgba(70, 122, 47, 0.14);
  color: var(--success);
}

.status-expiring_soon {
  background: rgba(176, 106, 22, 0.14);
  color: var(--warning);
}

.status-expired,
.status-invalid {
  background: rgba(178, 68, 104, 0.14);
  color: var(--danger);
}

.status-not_registered {
  background: rgba(47, 104, 184, 0.14);
  color: var(--info);
}

/* nicer small text for numeric/status columns */
td,
th,
.pag-info,
.form-group label,
.sec-label {
  font-variant-numeric: tabular-nums;
}

/* SCROLLBAR */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 999px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* Tablet */
@media (max-width: 1100px) {
  .body-wrap {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .main-area {
    min-width: 0;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .app {
    padding: 12px;
  }

  .topbar {
    min-height: auto;
    padding: 14px;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-left,
  .topbar-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .topbar-divider {
    display: none;
  }

  .stats-inline {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    flex-wrap: nowrap;
  }

  .sidebar,
  .main-area {
    border-radius: 18px;
  }

  .sidebar {
    padding: 14px;
  }

  .sidebar-section {
    padding: 14px;
  }

  .toolbar {
    padding: 14px;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-search,
  .toolbar > select {
    width: 100%;
    min-width: 0;
  }

  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .pag-left,
  .pag-right {
    width: 100%;
  }

  .pag-right {
    justify-content: flex-start;
  }

  .export-panel,
  .modal-overlay {
    padding: 12px;
  }

  .export-box,
  .modal {
    width: 100%;
    padding: 16px;
    border-radius: 18px;
  }

  #toast-container {
    right: 12px;
    left: 12px;
    bottom: 12px;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }
}

/* Mobile card table */
@media (max-width: 640px) {
  .table-area {
    overflow: visible;
    padding: 10px;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tbody tr {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
  }

  tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--divider);
    text-align: right;
  }

  tbody td:last-child {
    border-bottom: 0;
  }

  tbody td::before {
    content: attr(data-label);
    flex: 0 0 42%;
    text-align: left;
    font-size: 12px;
    font-weight: 800;
    color: var(--muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .empty-state {
    min-height: 240px;
  }
}
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.12); /* di light → pakai surface-2 */
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  backdrop-filter: blur(6px);
}

[data-theme="light"] .stat-pill {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(0, 0, 0, 0.05);
}

.stat-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.stat-pill strong {
  font-weight: 700;
  color: var(--text);
}

.stat-pill span.label {
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 10px;
}

.stat-pill.active-filter {
  border-color: var(--primary);
  background: var(--primary-soft);
}
/* GROUP PANEL */
#groupList {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
  scroll-behavior: smooth;
}

#groupList::-webkit-scrollbar {
  width: 8px;
}

#groupList::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 999px;
}

#groupList::-webkit-scrollbar-track {
  background: transparent;
}

.group-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 10px 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-solid), var(--surface-2));
  transition: 0.18s ease;
}

.group-item:hover {
  background: var(--surface-2);
  border-color: rgba(255, 255, 255, 0.1);
}

.group-item.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary-soft) 70%, var(--surface-solid));
  box-shadow: inset 0 0 0 1px rgba(15, 123, 131, 0.12);
}

.g-info {
  min-width: 0;
  cursor: pointer;
}

.g-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.g-meta {
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g-meta .ok {
  color: var(--success);
  font-weight: 700;
}

.g-meta .exp {
  color: var(--danger);
  font-weight: 700;
}

.g-del {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: 0.18s ease;
}

.g-del:hover {
  opacity: 1;
  color: var(--danger);
  border-color: rgba(210, 122, 155, 0.25);
  background: rgba(210, 122, 155, 0.08);
}

/* mobile */
@media (max-width: 768px) {
  #groupList {
    max-height: 320px;
  }

  .group-item {
    min-height: 54px;
    padding: 9px 9px 9px 11px;
  }

  .g-name {
    font-size: 13px;
  }

  .g-meta {
    font-size: 10px;
  }

  .g-del {
    width: 28px;
    height: 28px;
    min-width: 28px;
  }
}
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-actions .btn {
  position: relative;
  overflow: hidden;
  min-width: 42px;
}

.row-actions .btn:active {
  transform: scale(0.96);
}

.row-actions .btn.is-loading {
  pointer-events: none;
  opacity: 0.85;
}

.row-actions .btn.is-loading .btn-label,
.row-actions .btn.is-loading svg,
.row-actions .btn.is-loading .btn-text {
  opacity: 0;
}

.row-actions .btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
}

.row-actions.is-busy .btn:not(.is-loading) {
  opacity: 0.45;
  pointer-events: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.btn {
  position: relative;
  overflow: hidden;
}

.btn .btn-label,
.btn .btn-text,
.btn svg {
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-loading,
.btn.is-loading {
  pointer-events: none;
}

.btn-loading .btn-label,
.btn-loading .btn-text,
.btn-loading svg,
.btn.is-loading .btn-label,
.btn.is-loading .btn-text,
.btn.is-loading svg {
  opacity: 0;
}

.btn-loading::after,
.btn.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  margin-left: -7px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: currentColor;
  animation: btnSpin 0.7s linear infinite;
}

.btn-ghost.btn-loading::after,
.btn-ghost.is-loading::after {
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-top-color: currentColor;
}

@keyframes btnSpin {
  to {
    transform: rotate(360deg);
  }
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 12px 6px 8px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  max-width: 240px;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, var(--primary), var(--primary-hover));
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
}

.user-meta {
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}

.user-role {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}

.logout-btn {
  text-decoration: none;
}

.logout-btn:hover {
  border-color: rgba(210, 122, 155, 0.24);
  color: var(--danger);
  background: rgba(210, 122, 155, 0.08);
}

@media (max-width: 768px) {
  .user-chip {
    width: 100%;
    max-width: none;
    order: -1;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }
}
