@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --color-bg: #f4f6fb;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-border-soft: #eef2f7;
  --color-text: #0f172a;
  --color-muted: #64748b;
  --color-blue: #2563eb;
  --color-blue-dark: #1d4ed8;
  --color-orange: #f97316;
  --color-navy: #0b1220;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 40px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.12);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --nav-bg: rgba(37, 99, 235, 0.06);
  --nav-active: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(249, 115, 22, 0.08));
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  overflow-x: hidden;
}

body.nav-open,
body.modal-open {
  overflow: hidden;
}

/* Decorative page background */
.app-shell {
  position: relative;
  min-height: 100vh;
  isolation: isolate;
}

.app-shell::before,
.app-shell::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  pointer-events: none;
  z-index: -1;
}

.app-shell::before {
  width: 420px;
  height: 420px;
  top: -120px;
  right: -80px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.22), transparent 70%);
}

.app-shell::after {
  width: 360px;
  height: 360px;
  bottom: -100px;
  left: -60px;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.18), transparent 70%);
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.app-header__inner {
  max-width: 80rem;
  margin: 0 auto;
  padding: 0.85rem 1rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Notifikasi lonceng */
.app-notif {
  position: relative;
  flex-shrink: 0;
}

.app-notif__btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.app-notif__btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.app-notif--active .app-notif__icon {
  animation: notif-ring 0.6s ease-in-out;
}

@keyframes notif-ring {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(14deg); }
  40% { transform: rotate(-12deg); }
  60% { transform: rotate(8deg); }
  80% { transform: rotate(-6deg); }
}

.app-notif__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: #f97316;
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1.125rem;
  text-align: center;
  box-shadow: 0 0 0 2px #0b1220;
}

.app-notif__panel {
  position: fixed;
  z-index: 9999;
  width: 340px;
  max-width: calc(100vw - 16px);
  min-width: 280px;
  max-height: min(24rem, calc(100vh - 5rem));
  overflow: hidden;
  display: none;
  flex-direction: column;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
}

.app-notif__panel.is-open {
  display: flex !important;
}

.app-notif__panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.app-notif__panel-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
}

.app-notif__panel-link {
  font-size: 0.75rem;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
  white-space: nowrap;
}

.app-notif__panel-link:hover {
  text-decoration: underline;
}

.app-notif__list {
  overflow-y: auto;
  max-height: min(20rem, calc(100vh - 9rem));
}

.app-notif__empty {
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #64748b;
}

.app-notif__item {
  display: block;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s ease;
}

.app-notif__item:hover {
  background: #f8fafc;
}

.app-notif__item--unread {
  background: #fff7ed;
  border-left: 3px solid #f97316;
  padding-left: calc(1rem - 3px);
}

.app-notif__item-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #0f172a;
}

.app-notif__item-body {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  line-height: 1.45;
  color: #475569;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.app-notif__item-time {
  margin-top: 0.35rem;
  font-size: 0.6875rem;
  color: #94a3b8;
}

.app-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.app-nav-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

.app-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}

body.nav-open .app-sidebar-backdrop {
  display: block;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.app-brand__logo {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-blue) 0%, var(--color-orange) 100%);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.app-brand__logo:has(.app-brand__logo-img) {
  background: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.app-brand__logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.login-card__icon {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: grid;
  place-items: center;
  margin-bottom: 1rem;
  overflow: hidden;
  backdrop-filter: blur(8px);
}

.login-card__icon:has(.login-card__logo-img) {
  background: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.login-card__logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.app-brand__logo svg {
  width: 1.15rem !important;
  height: 1.15rem !important;
  max-width: 1.15rem;
  max-height: 1.15rem;
  color: white;
  flex-shrink: 0;
}

.app-brand__title {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.app-brand__sub {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.65);
  font-weight: 500;
}

.app-user-chip {
  display: none;
  text-align: right;
}

@media (min-width: 640px) {
  .app-user-chip {
    display: block;
  }
}

.app-user-chip__name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
}

.app-user-chip__role {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
}

/* Sidebar */
.app-sidebar {
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  border: 1px solid var(--color-border-soft);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 7rem);
  position: sticky;
  top: 5.5rem;
}

.app-sidebar__head {
  flex-shrink: 0;
}

.app-sidebar__nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(37, 99, 235, 0.35) transparent;
}

.app-sidebar__nav::-webkit-scrollbar {
  width: 6px;
}

.app-sidebar__nav::-webkit-scrollbar-thumb {
  background: rgba(37, 99, 235, 0.3);
  border-radius: 999px;
}

.app-sidebar__nav::-webkit-scrollbar-thumb:hover {
  background: rgba(37, 99, 235, 0.5);
}

.app-sidebar__head {
  padding: 1.1rem 1.25rem;
  background: linear-gradient(135deg, var(--color-blue) 0%, #3b82f6 45%, var(--color-orange) 100%);
  color: #fff;
}

.app-sidebar__head-title {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.app-sidebar__head-sub {
  font-size: 0.7rem;
  opacity: 0.88;
  margin-top: 0.15rem;
}

.app-sidebar__nav nav {
  padding: 0.5rem 0.5rem 0.75rem;
}

.nav-section {
  margin-top: 0.5rem;
  padding: 0.35rem 0.75rem 0.25rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  color: #334155;
  font-weight: 600;
  font-size: 0.8125rem;
  text-decoration: none;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.nav-item:hover {
  background: var(--nav-bg);
  color: var(--color-blue-dark);
}

.nav-item.is-active {
  background: var(--nav-active);
  color: var(--color-blue-dark);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}

.nav-item svg {
  width: 1.1rem !important;
  height: 1.1rem !important;
  max-width: 1.1rem;
  max-height: 1.1rem;
  flex-shrink: 0;
  opacity: 0.75;
}

.nav-item.is-active svg {
  opacity: 1;
  color: var(--color-blue);
}

/* Main content card */
.app-main-card {
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  border: 1px solid var(--color-border-soft);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.app-main-card__head {
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid var(--color-border-soft);
  background: linear-gradient(180deg, #fafbfd 0%, #fff 100%);
}

.app-main-card__title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--color-text);
}

.app-main-card__sub {
  font-size: 0.8125rem;
  color: var(--color-muted);
  margin-top: 0.15rem;
}

.app-main-card__body {
  padding: 1.35rem;
}

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1rem;
  line-height: 1.45;
}

.alert--success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.alert--error {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
}

/* Forms – global in main */
.app-main-card__body input[type="text"],
.app-main-card__body input[type="password"],
.app-main-card__body input[type="email"],
.app-main-card__body input[type="number"],
.app-main-card__body input[type="date"],
.app-main-card__body input[type="time"],
.app-main-card__body input[type="search"],
.app-main-card__body input[type="file"],
.app-main-card__body select,
.app-main-card__body textarea,
.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.95rem;
  font-size: 0.875rem;
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.login-card input::placeholder {
  color: #94a3b8;
}

.app-main-card__body input:focus,
.app-main-card__body select:focus,
.app-main-card__body textarea:focus,
.login-card input:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.45);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.app-main-card__body label,
.login-card label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.4rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition), background var(--transition);
  line-height: 1.2;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-navy) 0%, #1e293b 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(11, 18, 32, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 10px 28px rgba(11, 18, 32, 0.3);
}

.btn-accent {
  background: linear-gradient(135deg, var(--color-blue) 0%, #3b82f6 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.3);
}

.btn-accent:hover {
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.38);
}

.btn-outline {
  background: #fff;
  color: #334155;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-xs);
}

.btn-outline:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.btn-ghost-header {
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-decoration: none;
  transition: background var(--transition);
}

.btn-ghost-header:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* Tables */
.app-main-card__body .overflow-auto,
.table-wrap {
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-soft);
  overflow: auto;
  box-shadow: var(--shadow-xs);
}

.app-main-card__body table {
  width: 100%;
  font-size: 0.8125rem;
  border-collapse: collapse;
}

.app-main-card__body table thead {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.app-main-card__body table thead th {
  text-align: left;
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.app-main-card__body table tbody td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--color-border-soft);
  vertical-align: middle;
}

.app-main-card__body table tbody tr {
  transition: background var(--transition);
}

.app-main-card__body table tbody tr:hover {
  background: #f8fafc;
}

.app-main-card__body table tbody tr:last-child td {
  border-bottom: none;
}

.app-main-card__body table a {
  color: var(--color-blue);
  font-weight: 600;
  text-decoration: none;
}

.app-main-card__body table a:hover {
  text-decoration: underline;
}

/* Stat cards (dashboard) */
.stat-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-soft);
  padding: 1.25rem;
  background: var(--color-surface);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-sm);
}

.stat-card--gradient {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.06) 0%, rgba(249, 115, 22, 0.05) 100%);
  border-color: rgba(37, 99, 235, 0.12);
}

.stat-card__label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.stat-card__value {
  margin-top: 0.5rem;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--color-text);
  line-height: 1.1;
}

.stat-card__desc {
  margin-top: 0.35rem;
  font-size: 0.8125rem;
  color: var(--color-muted);
}

.stat-card__highlight {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--color-border-soft);
}

/* Login page */
.login-page .app-layout-main {
  max-width: 28rem;
  margin: 0 auto;
  padding-top: clamp(2rem, 8vh, 4rem);
  padding-bottom: 3rem;
  min-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-page .app-main-card,
.login-page .app-main-card__head {
  display: none;
}

.login-card {
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  border: 1px solid var(--color-border-soft);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: loginFadeIn 0.5s ease-out;
}

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

.login-card__hero {
  position: relative;
  padding: 2rem 1.75rem 1.75rem;
  background: linear-gradient(145deg, #1e3a8a 0%, #2563eb 55%, #ea580c 100%);
  color: #fff;
  overflow: hidden;
}

.login-card__hero::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.login-card__hero::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.login-card__hero-inner {
  position: relative;
  z-index: 1;
}

.login-card__icon svg {
  width: 1.5rem !important;
  height: 1.5rem !important;
  max-width: 1.5rem;
  max-height: 1.5rem;
  color: #fff;
}

/* Tailwind CDN loads after app.css – keep inline icons from scaling up */
.app-shell svg.icon,
.app-shell .icon-svg {
  width: 1.25rem !important;
  height: 1.25rem !important;
  max-width: 1.25rem;
  max-height: 1.25rem;
  flex-shrink: 0;
}

.app-shell .app-brand__logo .icon-svg {
  width: 1.15rem !important;
  height: 1.15rem !important;
  max-width: 1.15rem;
  max-height: 1.15rem;
}

.login-card__title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: #fff;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
}

.login-card__sub {
  font-size: 0.875rem;
  margin-top: 0.2rem;
  color: rgba(255, 255, 255, 0.95);
}

.login-card__hint {
  margin-top: 1rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
}

.login-card__body {
  padding: 1.75rem;
}

.login-card .btn-login {
  width: 100%;
  padding: 0.85rem 1rem;
  margin-top: 0.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: inherit;
  background: linear-gradient(135deg, var(--color-navy) 0%, #1e3a5f 100%);
  box-shadow: 0 8px 24px rgba(11, 18, 32, 0.28);
  transition: transform var(--transition), box-shadow var(--transition);
}

.login-card .btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(11, 18, 32, 0.34);
}

.login-card .password-toggle {
  position: absolute;
  inset: 0 0 0 auto;
  width: 2.75rem;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  transition: color var(--transition);
}

.login-card .password-toggle:hover {
  color: #475569;
}

.login-card .password-field {
  position: relative;
}

.login-card .password-field input {
  padding-right: 2.75rem;
}

.login-remember {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: #334155;
  cursor: pointer;
  user-select: none;
}

.login-remember input {
  width: auto;
  margin-top: 0.15rem;
  accent-color: var(--color-blue);
}

.login-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: #475569;
}

/* Modal — scroll overlay supaya header tidak terpotong */
[id^="modal-"] {
  z-index: 50;
  padding: max(1rem, env(safe-area-inset-top)) 0.75rem max(1rem, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: center !important;
  justify-content: flex-start !important;
}

[id^="modal-"].flex {
  display: flex !important;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
}

[id^="modal-"] > .app-modal__panel,
[id^="modal-"] > div {
  flex-shrink: 0;
  width: 100%;
  max-width: 42rem;
  margin-top: auto;
  margin-bottom: auto;
  max-height: calc(100dvh - 2rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-modal__head {
  flex-shrink: 0;
}

.app-modal__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

[id^="modal-"] .rounded-2xl,
[id^="modal-"] .rounded-3xl,
.app-modal__panel {
  box-shadow: var(--shadow-lg);
}

/* Table horizontal scroll — hint di atas daftar, scroll hanya area tabel */
.table-scroll-block {
  min-width: 0;
  max-width: 100%;
}

.table-scroll-hint {
  display: none;
  margin: 0;
  padding: 0.4rem 0.65rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-muted);
  text-align: center;
  background: #f8fafc;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.table-scroll-block .table-scroll {
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.table-scroll,
.app-main-card__body .overflow-auto {
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
}

.table-scroll::after,
.table-scroll-block .table-scroll::after,
.app-main-card__body .overflow-auto:has(table)::after {
  content: none;
  display: none;
}

@media (max-width: 767px) {
  .table-scroll-block .table-scroll-hint {
    display: block;
  }
}

/* Tools iframe */
.app-main-card__body--iframe {
  padding: 0;
}

.tool-frame-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--color-border-soft);
  background: #f8fafc;
}

.tool-frame-toolbar__hint {
  font-size: 0.75rem;
  color: var(--color-muted);
}

.tool-search {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.tool-search__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-muted);
  white-space: nowrap;
}

.tool-search__input {
  flex: 1;
  min-width: 180px;
  max-width: 420px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  font-family: inherit;
  background: #fff;
}

.tool-search__input:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.tool-search__count {
  font-size: 0.75rem;
  color: var(--color-muted);
  font-weight: 600;
}

.tool-frame-wrap {
  position: relative;
  width: 100%;
  height: calc(100vh - 220px);
  min-height: 480px;
  background: #fff;
}

.tool-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

/* Badge role */
.badge-role {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(249, 115, 22, 0.08));
  color: var(--color-blue-dark);
}

/* ========== Mobile & tablet ========== */
@media (max-width: 1023px) {
  .has-sidebar .app-nav-toggle {
    display: inline-flex;
  }

  .app-sidebar-wrap {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    width: min(18.5rem, 88vw);
    height: 100%;
    height: 100dvh;
    padding: 0;
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
  }

  body.nav-open .app-sidebar-wrap {
    transform: translateX(0);
    pointer-events: auto;
  }

  .app-sidebar-wrap .app-sidebar {
    max-height: 100%;
    height: 100%;
    top: 0;
    position: relative;
    border-radius: 0;
    border-right: 1px solid var(--color-border-soft);
    box-shadow: var(--shadow-lg);
  }

  .app-sidebar__nav {
    max-height: none;
  }

  .nav-item {
    min-height: 2.75rem;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .app-brand__sub {
    display: none;
  }

  .app-brand__title {
    font-size: 0.85rem;
  }

  .btn-ghost-header {
    padding: 0.45rem 0.65rem;
    font-size: 0.75rem;
  }

  .app-layout-main {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .app-main-card__head {
    padding: 1rem 1.1rem;
  }

  .app-main-card__body {
    padding: 1rem;
  }

  .app-main-card__title {
    font-size: 1rem;
  }

  .tool-frame-wrap {
    height: calc(100dvh - 12rem);
    min-height: 320px;
  }

  .tool-search__input {
    max-width: none;
    min-width: 0;
    width: 100%;
  }

  .tool-frame-toolbar .btn {
    width: 100%;
    justify-content: center;
  }

  /* Stack filter forms & toolbars */
  .app-main-card__body > .flex.flex-col > .flex.flex-col.md\:flex-row form.flex,
  .app-main-card__body > .flex.flex-col > .flex.flex-col.md\:flex-row > form.flex {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .app-main-card__body .flex.items-end.gap-2 {
    flex-direction: column;
    align-items: stretch !important;
    width: 100%;
  }

  .app-main-card__body .flex.items-end.gap-2 .btn,
  .app-main-card__body .flex.items-end.gap-2 a.btn {
    width: 100%;
    justify-content: center;
  }

  .app-main-card__body .shrink-0 .btn,
  .app-main-card__body .shrink-0 a.btn {
    width: 100%;
  }

  .app-main-card__body .grid.grid-cols-1.md\:grid-cols-6 {
    grid-template-columns: 1fr !important;
  }

  .app-main-card__body .grid.grid-cols-1.md\:grid-cols-6 .md\:col-span-2 {
    grid-column: span 1 !important;
  }

  .app-main-card__body form.grid {
    grid-template-columns: 1fr !important;
  }

  .app-main-card__body form.grid .flex.gap-2 {
    flex-direction: column;
    align-items: stretch !important;
    justify-content: flex-start !important;
  }

  .app-main-card__body form.grid .flex.gap-2 .btn,
  .app-main-card__body form.grid .flex.gap-2 a,
  .app-main-card__body form.grid .flex.gap-2 button {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .login-card__hero {
    padding: 1.5rem 1.25rem 1.25rem;
  }

  .login-card__body {
    padding: 1.25rem;
  }

  .login-page .app-layout-main {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }

  [id^="modal-"] > .app-modal__panel,
  [id^="modal-"] > div {
    max-width: 100% !important;
  }

  .stat-card__value {
    font-size: 1.5rem;
  }
}

@media (max-width: 380px) {
  .app-brand__logo {
    width: 2.15rem;
    height: 2.15rem;
  }

  .app-header__inner {
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
  }
}

@media (min-width: 1024px) {
  .app-sidebar-backdrop {
    display: none !important;
  }
}

/* Searchable select (combobox) */
.searchable-select {
  position: relative;
}

.searchable-select__native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.searchable-select__dropdown {
  position: absolute;
  z-index: 60;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-soft, 0 10px 30px rgba(2, 6, 23, 0.1));
}

.searchable-select__dropdown--fixed {
  position: fixed;
  z-index: 80;
  right: auto;
}

.searchable-select__option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.85rem;
  font-size: 0.875rem;
  color: var(--color-text);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.searchable-select__option:hover,
.searchable-select__option:focus {
  background: #f1f5f9;
  outline: none;
}

.searchable-select__empty {
  padding: 0.65rem 0.85rem;
  font-size: 0.8125rem;
  color: #64748b;
}
