:root {
  --bg-page: #F8FAFC;
  --bg-canvas: #F8FAFC;
  --bg-card: #FFFFFF;
  --surface-card: #FFFFFF;
  --bg-muted: #F1F5F9;
  --text-main: #0F172A;
  --text-secondary: #334155;
  --text-muted: #64748B;
  --border-color: #E2E8F0;
  --border-hairline: #E2E8F0;
  --border-focus: #2563EB;
  --primary: #0F172A;
  --navy: #0F172A;
  --primary-hover: #1E293B;
  --accent: #2563EB;
  --royal: #2563EB;
  --danger-bg: #FEF2F2;
  --danger-text: #DC2626;
  --danger-border: #FECACA;
  --success-bg: #DCFCE7;
  --success-text: #166534;
  --warning-bg: #FEF3C7;
  --warning-text: #92400E;
  --info-bg: #DBEAFE;
  --info-text: #1E40AF;
  --radius-card: 10px;
  --card-radius: 10px;
  --radius-input: 7px;
  --radius-pill: 9999px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { margin-top: 0; color: var(--text-main); font-weight: 600; }
p { margin-top: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg, video, canvas { max-width: 100%; height: auto; }

.tabular-nums, .font-monospace, td.num, th.num {
  font-variant-numeric: tabular-nums;
}

/* Sticky 2-Row Compact Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: var(--bg-card);
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  padding: 0;
}

.app-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.app-brand-title { font-size: 15px; font-weight: 700; color: var(--text-main); margin: 0; line-height: 1.25; }
.app-brand-sub { font-size: 12px; color: var(--text-muted); margin: 0; line-height: 1.25; }
.app-header-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Horizontal 1-Row Underline Tabs */
.app-tabs-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
  border-top: 1px solid var(--border-color);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.app-tabs-wrap::-webkit-scrollbar { display: none; }

.app-tabs, .nav-tabs, .nav-pills {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
  white-space: nowrap;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-color);
}
.app-tabs-wrap .app-tabs { border-bottom: none; }

.app-tab, .nav-tabs .nav-link, .nav-pills .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.app-tab:hover, .nav-tabs .nav-link:hover, .nav-pills .nav-link:hover {
  color: var(--text-main);
  text-decoration: none;
}
.app-tab.active, .nav-tabs .nav-link.active, .nav-pills .nav-link.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
  background: transparent;
}

.tab-content > .tab-pane { display: none; }
.tab-content > .tab-pane.active, .tab-content > .tab-pane.show { display: block; }

/* Containers & Grid */
.container, .container-fluid, .container-lg, .container-xl {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  margin-left: -6px;
  margin-right: -6px;
}
.row > * {
  padding-left: 6px;
  padding-right: 6px;
  width: 100%;
  min-width: 0;
}
.col { flex: 1 0 0%; }
.col-auto { flex: 0 0 auto; width: auto; }
.col-6 { width: 50%; }
.col-12 { width: 100%; }
@media (min-width: 768px) {
  .col-md-2 { width: 16.6667%; }
  .col-md-3 { width: 25%; }
  .col-md-4 { width: 33.3333%; }
  .col-md-5 { width: 41.6667%; }
  .col-md-6 { width: 50%; }
  .col-md-7 { width: 58.3333%; }
  .col-md-8 { width: 66.6667%; }
  .col-md-9 { width: 75%; }
  .col-md-10 { width: 83.3333%; }
  .col-md-12 { width: 100%; }
}
@media (min-width: 992px) {
  .col-lg-2 { width: 16.6667%; }
  .col-lg-3 { width: 25%; }
  .col-lg-4 { width: 33.3333%; }
  .col-lg-5 { width: 41.6667%; }
  .col-lg-6 { width: 50%; }
  .col-lg-7 { width: 58.3333%; }
  .col-lg-8 { width: 66.6667%; }
  .col-lg-9 { width: 75%; }
  .col-lg-12 { width: 100%; }
}

/* Clean Cards */
.card, .app-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  margin-bottom: 14px;
  max-width: 100%;
  min-width: 0;
}
.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background: transparent;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.card-body { padding: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin: 0 0 4px; }

/* Strict 3-Style Button Hierarchy (Anti-Pelangi) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-input);
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: #FFFFFF;
  color: var(--text-main);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn:hover:not(:disabled) { background: var(--bg-page); border-color: #CBD5E1; text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: 14px; }

.btn-primary, .btn-primary-theme {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled), .btn-primary-theme:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #FFFFFF;
}

.btn-secondary, .btn-light, .btn-outline-secondary, .btn-outline-primary,
.btn-outline-light, .btn-outline-dark, .btn-info, .btn-outline-info,
.btn-warning, .btn-outline-warning, .btn-success, .btn-outline-success {
  background: #FFFFFF;
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover:not(:disabled), .btn-light:hover:not(:disabled),
.btn-outline-secondary:hover:not(:disabled), .btn-outline-primary:hover:not(:disabled),
.btn-info:hover:not(:disabled), .btn-warning:hover:not(:disabled),
.btn-success:hover:not(:disabled) {
  background: var(--bg-page);
  border-color: #CBD5E1;
  color: var(--text-main);
}

.btn-danger, .btn-outline-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}
.btn-danger:hover:not(:disabled), .btn-outline-danger:hover:not(:disabled) {
  background: #FEE2E2;
  border-color: #FCA5A5;
  color: var(--danger-text);
}

.btn-close {
  background: transparent;
  border: none;
  width: 28px;
  height: 28px;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}
.btn-close::before { content: "\00D7"; }

/* Clean Form Controls */
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.form-control, .form-select {
  display: block;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-main);
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-input);
  outline: none;
}
.form-control-sm, .form-select-sm { height: 32px; font-size: 12px; padding: 0 10px; }
textarea.form-control { height: auto; min-height: 80px; padding: 8px 12px; resize: vertical; }
.form-control:focus, .form-select:focus { border-color: var(--border-focus); }
.input-group { display: flex; align-items: stretch; gap: 6px; }
.input-group .form-control { flex: 1; min-width: 0; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check-input { width: 16px; height: 16px; cursor: pointer; }

/* Horizontal-Only Tables */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
  margin: 0;
}
.table th, .table thead th {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-page);
  border-top: none;
  border-left: none;
  border-right: none;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.table td {
  padding: 10px 12px;
  border-top: none;
  border-left: none;
  border-right: none;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover td { background: var(--bg-page); }

/* Pastel Pill Badges */
.badge, .badge-duk {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  background: var(--bg-muted);
  color: var(--text-secondary);
}
.badge.bg-success, .badge-success { background: var(--success-bg) !important; color: var(--success-text) !important; }
.badge.bg-warning, .badge-warning { background: var(--warning-bg) !important; color: var(--warning-text) !important; }
.badge.bg-danger, .badge-danger { background: var(--danger-bg) !important; color: var(--danger-text) !important; }
.badge.bg-primary, .badge.bg-info, .badge-info { background: var(--info-bg) !important; color: var(--info-text) !important; }
.badge.bg-secondary, .badge.bg-light { background: var(--bg-muted) !important; color: var(--text-secondary) !important; }

/* Alerts */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-input);
  border: 1px solid var(--border-color);
  font-size: 13px;
  margin-bottom: 12px;
  background: var(--bg-page);
}
.alert-danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); border-color: #FDE68A; }
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: #BBF7D0; }
.alert-info { background: var(--info-bg); color: var(--info-text); border-color: #BFDBFE; }

/* Modals & Toasts */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  padding: 16px;
  overflow-y: auto;
}
.modal.show { display: flex; }
.modal-dialog { width: 100%; max-width: 540px; margin: auto; }
.modal-dialog.modal-lg { max-width: 780px; }
.modal-dialog.modal-xl { max-width: 1020px; }
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}
.modal-title { font-size: 15px; font-weight: 600; margin: 0; }
.modal-body { padding: 16px; max-height: 75vh; overflow-y: auto; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

.toast-container { position: fixed; bottom: 16px; right: 16px; z-index: 1100; }
.toast { display: none; background: var(--primary); color: #FFFFFF; border-radius: var(--radius-input); padding: 10px 14px; font-size: 13px; }
.toast.show { display: block; }

/* Lightweight Utilities */
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-none { display: none !important; }
.flex-wrap { flex-wrap: wrap; }
.flex-grow-1 { flex-grow: 1; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.justify-content-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.g-2 { row-gap: 8px; }
.g-3 { row-gap: 12px; }
.w-100 { width: 100%; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.me-1 { margin-right: 4px; }
.me-2 { margin-right: 8px; }
.ms-auto { margin-left: auto; }
.small, small { font-size: 12px; }
.fw-semibold { font-weight: 600; }
.fw-bold { font-weight: 700; }
.text-muted { color: var(--text-muted) !important; }
.text-danger { color: var(--danger-text) !important; }
.text-success { color: var(--success-text) !important; }
.text-primary { color: var(--accent) !important; }
.text-center { text-align: center; }
.text-end { text-align: right; }
.bg-light { background: var(--bg-page) !important; }
.bg-white { background: var(--bg-card) !important; }
.border { border: 1px solid var(--border-color) !important; }
.rounded { border-radius: var(--radius-input) !important; }
.rounded-3 { border-radius: var(--radius-card) !important; }
.spinner-border { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border-color); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
