/* ============================================
   Dashboard Berita Ekonomi — Sensus Ekonomi 2026
   Color System & Design Tokens
   ============================================ */

:root {
    /* Primary Palette — SE2026 Orange */
    --orange-50: #FFF8F0;
    --orange-100: #FFF0E0;
    --orange-200: #FFDCB8;
    --orange-300: #FFC48A;
    --orange-400: #FFA54D;
    --orange-500: #E8700A;
    --orange-600: #C45D00;
    --orange-700: #9E4A00;
    --orange-800: #7A3900;

    /* Neutrals */
    --white: #FFFFFF;
    --gray-50: #F8F9FA;
    --gray-100: #F1F3F5;
    --gray-200: #E9ECEF;
    --gray-300: #DEE2E6;
    --gray-400: #CED4DA;
    --gray-500: #ADB5BD;
    --gray-600: #6C757D;
    --gray-700: #495057;
    --gray-800: #343A40;
    --gray-900: #1A1A2E;

    /* Semantic */
    --bg-body: var(--gray-50);
    --bg-card: var(--white);
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-600);
    --text-muted: var(--gray-500);
    --border-color: var(--gray-200);
    --border: var(--border-color);
    --accent: var(--orange-500);
    --accent-hover: var(--orange-600);
    --accent-light: var(--orange-100);
    --accent-bg: var(--orange-50);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
    --shadow-accent: 0 4px 14px rgba(232, 112, 10, 0.25);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Font */
    --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ============================================
   Reset & Base
   ============================================ */

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

h1,
h2,
h3 {
    line-height: 1.3;
    font-weight: 700;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ============================================
   Header
   ============================================ */

.header {
    background: var(--white);
    border-bottom: 3px solid var(--accent);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

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

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

.header-logo {
    flex-shrink: 0;
}

.header-text h1 {
    font-size: 1.35rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.header-subtitle {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.header-timestamp {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 500;
}

/* ============================================
   Main Layout
   ============================================ */

.main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 24px 60px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* ============================================
   Welcome / About Card
   ============================================ */

.welcome-section {
    animation: fadeInUp 0.4s ease both;
}

.welcome-card {
    position: relative;
    background: var(--white);
    border: 1px solid var(--orange-200);
    border-radius: var(--radius-lg);
    padding: 28px 32px 24px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.welcome-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--orange-500) 0%, var(--orange-300) 60%, var(--orange-200) 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.welcome-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
}

.welcome-close:hover {
    background: var(--gray-200);
    color: var(--text-primary);
}

/* Header */
.welcome-header {
    margin-bottom: 20px;
    padding-right: 0;
}

.welcome-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    background: var(--accent-light);
    border-radius: 20px;
    padding: 4px 10px;
    margin-bottom: 10px;
}

.welcome-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 6px;
    line-height: 1.35;
}

.welcome-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 100%;
}

/* Sumber berita row */
.welcome-sources-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 22px;
    padding: 12px 16px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
}

.welcome-sources-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.welcome-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.welcome-chip {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--orange-700);
    background: var(--orange-100);
    border: 1px solid var(--orange-200);
    border-radius: 20px;
    padding: 3px 10px;
    white-space: nowrap;
}

/* Features grid */
.welcome-features {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.welcome-feature {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.welcome-feature:hover {
    border-color: var(--orange-300);
    box-shadow: var(--shadow-sm);
}

.wf-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wf-scrape  { background: #EFF6FF; color: #2563EB; }
.wf-kbli    { background: #F0FDF4; color: #16A34A; }
.wf-insight { background: #FFF7ED; color: var(--orange-600); }
.wf-chat    { background: #FAF5FF; color: #7C3AED; }

.wf-body strong {
    display: block;
    font-size: 0.83rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.35;
}

.wf-body p {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0;
}

.welcome-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.55;
}

.welcome-list li {
    margin: 0 0 4px;
}

.welcome-list li:last-child {
    margin-bottom: 0;
}

.welcome-guide-wrap {
    margin-top: 12px;
}

.welcome-guide-card {
    padding: 16px 18px;
    background: #fffaf4;
    border: 1px solid var(--orange-200);
    border-radius: var(--radius-md);
}

.welcome-guide-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.welcome-guide-title {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
}

.welcome-guide-subtitle {
    margin: 2px 0 0;
    font-size: 0.77rem;
    color: var(--text-secondary);
}

/* Collapse animation */
.welcome-section.is-hidden {
    display: none;
}

/* Responsive */
@media (max-width: 1024px) {
    .welcome-features {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .welcome-card {
        padding: 22px 20px 20px;
    }
    .welcome-features {
        grid-template-columns: 1fr;
    }
    .welcome-sources-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .welcome-guide-card {
        padding: 14px;
    }
}

/* ============================================
   Scrape Info Bar (visible for all users)
   ============================================ */

.scrape-info-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 20px;
    background: var(--white);
    border: 1px solid var(--orange-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.scrape-info-bar .last-scrape-badge {
    margin-top: 0;
}

/* ============================================
   Scrape Section
   ============================================ */

.scrape-card {
    background: linear-gradient(135deg, var(--orange-50) 0%, var(--white) 60%);
    border: 1px solid var(--orange-200);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    transition: box-shadow var(--transition-base);
}

.scrape-card:hover {
    box-shadow: var(--shadow-md);
}

.scrape-info h2 {
    font-size: 1.15rem;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.scrape-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-width: 540px;
    line-height: 1.6;
}

.last-scrape-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 5px 12px;
    background: var(--orange-100);
    border: 1px solid var(--orange-200);
    border-radius: 20px;
    font-size: 0.78rem;
    color: var(--orange-700);
}

.last-scrape-badge svg {
    color: var(--orange-600);
    flex-shrink: 0;
}

.last-scrape-badge strong {
    font-weight: 700;
    color: var(--orange-700);
}

.scrape-controls {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-shrink: 0;
}

.scrape-input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.scrape-input-group label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.scrape-input {
    width: 100px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--white);
    text-align: center;
    outline: none;
    transition: border-color var(--transition-fast);
}

.scrape-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232, 112, 10, 0.1);
}

.scrape-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.btn-scrape {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--orange-500) 0%, var(--orange-600) 100%);
    color: var(--white);
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-accent);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn-scrape:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(232, 112, 10, 0.35);
}

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

.btn-scrape.loading {
    pointer-events: none;
    opacity: 0.85;
}

.btn-scrape.loading .btn-icon,
.btn-scrape.loading .btn-text {
    opacity: 0;
}

.btn-loader {
    display: none;
    position: absolute;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn-scrape.loading .btn-loader {
    display: block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Progress Section
   ============================================ */

.progress-section {
    background: var(--white);
    border: 1px solid var(--orange-200);
    border-radius: var(--radius-lg);
    padding: 22px 28px;
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.progress-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.progress-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.progress-row {
    display: grid;
    grid-template-columns: 200px 1fr 48px;
    align-items: center;
    gap: 14px;
}

.progress-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.progress-source {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-primary);
}

.progress-status {
    font-size: 0.74rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-bar-track {
    height: 10px;
    background: var(--gray-200);
    border-radius: 99px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gray-400);
    border-radius: 99px;
    transition: width 0.4s ease;
    width: 0%;
}

.progress-bar-fill.running {
    background: linear-gradient(90deg, var(--orange-400), var(--orange-500));
    animation: progress-pulse 1.5s ease-in-out infinite;
}

.progress-bar-fill.done {
    background: #22c55e;
}

.progress-bar-fill.error {
    background: #ef4444;
}

@keyframes progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.progress-count {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: right;
    min-width: 32px;
}

/* ============================================
   Summary Cards
   ============================================ */

.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 22px 20px;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--orange-400);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: all var(--transition-base);
    opacity: 0;
    transform: translateY(12px);
    min-width: 0;
}

.stat-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    border-left-color: var(--orange-500);
}

.stat-card.card-highlight {
    background: linear-gradient(135deg, var(--orange-50) 0%, var(--white) 100%);
    border-left-color: var(--orange-500);
}

.stat-icon {
    width: 44px;
    height: 44px;
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent);
}

.stat-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.stat-value.text-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.stat-label {
    font-size: 0.76rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-period {
    font-size: 0.68rem;
    color: var(--orange-400);
    font-weight: 600;
    margin-top: 2px;
    letter-spacing: 0.02em;
}

/* ============================================
   Section Card (Chart + Table wrapper)
   ============================================ */

.section-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 28px;
    transition: box-shadow var(--transition-base);
}

.section-card:hover {
    box-shadow: var(--shadow-md);
}

.section-header {
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.08rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-header h2::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--accent);
    border-radius: 2px;
    flex-shrink: 0;
}

.section-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
    padding-left: 12px;
}

/* ============================================
   Chart
   ============================================ */

.chart-container {
    position: relative;
    width: 100%;
    max-height: 400px;
}

.chart-container-small {
    max-height: 320px;
}

/* ============================================
   Table Controls
   ============================================ */

.table-controls {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 20px;
    background: var(--white);
    color: var(--accent);
    border: 2px solid var(--accent);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.btn-download:hover {
    background: var(--accent);
    color: var(--white);
    box-shadow: var(--shadow-accent);
    transform: translateY(-1px);
}

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

.search-wrapper {
    position: relative;
    max-width: 380px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 11px 16px 11px 42px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.88rem;
    color: var(--text-primary);
    background: var(--gray-50);
    transition: all var(--transition-fast);
    outline: none;
}

.search-input:focus {
    border-color: var(--accent);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(232, 112, 10, 0.1);
}

.search-input::placeholder {
    color: var(--text-muted);
}

/* ============================================
   Date Filter
   ============================================ */

.date-filter-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 10px;
    background: var(--gray-50);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.date-filter-group:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232, 112, 10, 0.1);
    background: var(--white);
}

.date-filter-icon {
    color: var(--accent);
    flex-shrink: 0;
}

.date-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-input-wrap {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.date-input-wrap label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
}

.date-input {
    border: none;
    background: transparent;
    font-family: var(--font-family);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    outline: none;
    padding: 2px 0;
    cursor: pointer;
    width: 120px;
}

.date-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.5;
    filter: invert(0);
}

.date-input::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.date-separator {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
    flex-shrink: 0;
}

.btn-reset-date {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--gray-200);
    color: var(--text-secondary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    padding: 0;
}

.btn-reset-date:hover {
    background: var(--accent);
    color: var(--white);
}

.btn-reset-date.hidden {
    display: none;
}

/* ============================================
   Data Table
   ============================================ */

.table-responsive {
    overflow-x: auto;
    margin: 0 -28px;
    padding: 0 28px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.data-table thead {
    position: sticky;
    top: 0;
}

.data-table th {
    background: var(--gray-900);
    color: var(--white);
    padding: 13px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    border: none;
}

.data-table th:first-child {
    border-radius: var(--radius-sm) 0 0 0;
}

.data-table th:last-child {
    border-radius: 0 var(--radius-sm) 0 0;
}

.th-sortable {
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-fast);
}

.th-sortable:hover {
    background: var(--gray-800);
}

.th-sortable.active {
    background: var(--orange-700);
}

.sort-icon {
    margin-left: 6px;
    font-size: 0.75rem;
    opacity: 0.5;
}

.th-sortable.active .sort-icon {
    opacity: 1;
}

.th-no {
    width: 52px;
    text-align: center;
}

.th-link {
    width: 80px;
    text-align: center;
}

.th-source {
    width: 120px;
}

.th-date {
    width: 155px;
}

.th-tags {
    width: 200px;
}

.th-kbli {
    width: 260px;
}

.data-table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: top;
    color: var(--text-primary);
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--orange-50);
}

.data-table tbody tr:nth-child(even) {
    background: var(--gray-50);
}

.data-table tbody tr:nth-child(even):hover {
    background: var(--orange-50);
}

.td-no {
    text-align: center;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.82rem;
}

.td-judul {
    font-weight: 500;
    max-width: 380px;
    line-height: 1.5;
}

.td-source {
    white-space: nowrap;
    color: var(--text-secondary);
    font-weight: 600;
}

.td-date {
    white-space: nowrap;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.td-tags {
    max-width: 220px;
    white-space: normal;
    line-height: 1.7;
}

.td-kbli {
    max-width: 280px;
    white-space: normal;
    line-height: 1.5;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

/* ── KBLI: Badge berwarna per kategori ──────────────────────────────────────── */

.kbli-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 4px;
    border-radius: 20px;
    border: 1px solid transparent;
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: normal;
    max-width: 100%;
    transition: filter var(--transition-fast), transform var(--transition-fast);
}

.kbli-badge:hover {
    filter: brightness(0.94);
    transform: translateY(-1px);
}

.kbli-badge-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.68rem;
    font-weight: 800;
    flex-shrink: 0;
    letter-spacing: -0.01em;
    color: white;
}

.kbli-badge-text {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.35;
}

/* Color variants per group */
/* A — Pertanian: hijau */
.kbli-g-a { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }
.kbli-g-a .kbli-badge-letter { background: #059669; }
/* B — Pertambangan: coklat/abu */
.kbli-g-b { background: #fef9c3; border-color: #fde047; color: #713f12; }
.kbli-g-b .kbli-badge-letter { background: #ca8a04; }
/* C — Industri: biru indigo */
.kbli-g-c { background: #eef2ff; border-color: #a5b4fc; color: #3730a3; }
.kbli-g-c .kbli-badge-letter { background: #4f46e5; }
/* D — Listrik & Gas: kuning amber */
.kbli-g-d { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.kbli-g-d .kbli-badge-letter { background: #f59e0b; }
/* E — Air & Lingkungan: teal */
.kbli-g-e { background: #f0fdfa; border-color: #5eead4; color: #134e4a; }
.kbli-g-e .kbli-badge-letter { background: #0f9488; }
/* F — Konstruksi: oranye bata */
.kbli-g-f { background: #fff7ed; border-color: #fdba74; color: #9a3412; }
.kbli-g-f .kbli-badge-letter { background: #ea580c; }
/* G — Perdagangan: merah */
.kbli-g-g { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.kbli-g-g .kbli-badge-letter { background: #dc2626; }
/* H — Transportasi: biru */
.kbli-g-h { background: #eff6ff; border-color: #93c5fd; color: #1e3a5f; }
.kbli-g-h .kbli-badge-letter { background: #2563eb; }
/* I — Akomodasi: pink */
.kbli-g-i { background: #fdf2f8; border-color: #f0abfc; color: #86198f; }
.kbli-g-i .kbli-badge-letter { background: #c026d3; }
/* J — Informasi: violet */
.kbli-g-j { background: #f5f3ff; border-color: #c4b5fd; color: #4c1d95; }
.kbli-g-j .kbli-badge-letter { background: #7c3aed; }
/* K — Keuangan: hijau tua */
.kbli-g-k { background: #f0fdf4; border-color: #86efac; color: #14532d; }
.kbli-g-k .kbli-badge-letter { background: #16a34a; }
/* L — Real Estate: slate */
.kbli-g-l { background: #f8fafc; border-color: #94a3b8; color: #1e293b; }
.kbli-g-l .kbli-badge-letter { background: #475569; }
/* MN — Jasa Perusahaan: rose */
.kbli-g-mn { background: #fff1f2; border-color: #fda4af; color: #881337; }
.kbli-g-mn .kbli-badge-letter { background: #e11d48; }
/* O — Pemerintahan: biru navy */
.kbli-g-o { background: #eff6ff; border-color: #7dd3fc; color: #0c4a6e; }
.kbli-g-o .kbli-badge-letter { background: #0369a1; }
/* P — Pendidikan: hijau lime */
.kbli-g-p { background: #f7fee7; border-color: #a3e635; color: #365314; }
.kbli-g-p .kbli-badge-letter { background: #65a30d; }
/* Q — Kesehatan: merah muda */
.kbli-g-q { background: #fff0f3; border-color: #ffb3c1; color: #9b1d1d; }
.kbli-g-q .kbli-badge-letter { background: #e63950; }
/* RSTU — Jasa lainnya: abu-abu */
.kbli-g-rstu { background: #f9fafb; border-color: #d1d5db; color: #374151; }
.kbli-g-rstu .kbli-badge-letter { background: #6b7280; }
/* KE — Kemiskinan: merah tua */
.kbli-g-ke { background: #fef2f2; border-color: #fca5a5; color: #7f1d1d; }
.kbli-g-ke .kbli-badge-letter { background: #b91c1c; }
/* PG — Pengangguran: orange tua */
.kbli-g-pg { background: #fff7ed; border-color: #fb923c; color: #7c2d12; }
.kbli-g-pg .kbli-badge-letter { background: #c2410c; }

/* ── KBLI: Badge "Tidak Relevan" + tombol info ──────────────────────────────── */

.kbli-tidak-relevan {
    display: inline-block;
    padding: 2px 8px;
    background: var(--gray-100);
    color: var(--text-muted);
    border: 1px solid var(--gray-300);
    border-radius: 12px;
    font-size: 0.76rem;
    font-weight: 600;
    font-style: italic;
    vertical-align: middle;
    line-height: 1.6;
    white-space: nowrap;
}

.kbli-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    border: 1.5px solid var(--gray-300);
    border-radius: 50%;
    background: var(--white);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    margin-left: 5px;
    vertical-align: middle;
    flex-shrink: 0;
    transition: border-color var(--transition-fast), color var(--transition-fast),
                background var(--transition-fast);
}

.kbli-info-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-bg);
}

.kbli-info-btn svg {
    display: block;
    pointer-events: none;
}

/* Floating tooltip (diappend ke <body> via JS, posisi dihitung dinamis) */

.kbli-tooltip-floating {
    position: absolute;
    z-index: 9999;
    background: var(--gray-900);
    color: var(--white);
    font-family: var(--font-family);
    font-size: 0.76rem;
    font-weight: 500;
    line-height: 1.55;
    padding: 8px 12px 12px;
    border-radius: var(--radius-sm);
    max-width: 300px;
    white-space: normal;
    pointer-events: none;
    display: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

/* Segitiga bawah tooltip — posisi left diset via JS */
.kbli-tooltip-arrow {
    position: absolute;
    top: 100%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border: 5px solid transparent;
    border-top-color: var(--gray-900);
}

/* ── KBLI: Filter dropdown ───────────────────────────────────────────────────── */

/* ── Aktivitas Ekonomi: badge berwarna di dalam sel KBLI (mirip kbli-badge) ──── */

.aktivitas-badge {
    display: flex;
    width: fit-content;
    max-width: 100%;
    align-items: flex-start;
    gap: 6px;
    padding: 3px 9px 3px 4px;
    border-radius: 16px;
    border: 1px solid #67e8f9;
    background: #ecfeff;
    color: #155e75;
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: normal;
    margin-top: 7px;
    cursor: default;
    transition: filter var(--transition-fast), transform var(--transition-fast);
}

.aktivitas-badge:hover {
    filter: brightness(0.94);
    transform: translateY(-1px);
}

.aktivitas-badge-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.68rem;
    font-weight: 800;
    flex-shrink: 0;
    letter-spacing: -0.01em;
    color: white;
    background: #0891b2;
    margin-top: 1px;
}

.aktivitas-badge-text {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.35;
}

/* Nomor badge di filter dropdown Aktivitas */
.aktivitas-filter-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 18px;
    padding: 0 5px;
    background: var(--primary-color, #2563eb);
    color: #fff;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.kbli-filter-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.kbli-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    background: var(--gray-50);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    outline: none;
}

.kbli-filter-btn:hover,
.kbli-filter-btn.active {
    border-color: var(--accent);
    background: var(--white);
    color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232, 112, 10, 0.1);
}

.kbli-filter-btn .kbli-filter-chevron {
    transition: transform var(--transition-fast);
    opacity: 0.5;
}

.kbli-filter-btn.open .kbli-filter-chevron {
    transform: rotate(180deg);
    opacity: 1;
}

.kbli-filter-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.kbli-filter-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 200;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    min-width: 270px;
    max-height: 340px;
    overflow-y: auto;
    padding: 6px 0;
    display: none;
    scrollbar-width: thin;
}

.kbli-filter-menu.open {
    display: block;
    animation: fadeInUp 0.15s ease;
}

.kbli-filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-family);
}

.kbli-filter-option:hover {
    background: var(--orange-50);
    color: var(--accent);
}

.kbli-filter-option.selected {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 700;
}

.kbli-filter-option .kbli-filter-opt-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
}

.kbli-filter-sep {
    height: 1px;
    background: var(--gray-100);
    margin: 4px 0;
}

.kbli-filter-clear {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    font-family: var(--font-family);
    transition: background var(--transition-fast);
}

.kbli-filter-clear:hover {
    background: var(--orange-50);
}

.tag-chip {
    display: inline-block;
    padding: 3px 9px;
    margin: 2px 6px 2px 0;
    background: var(--accent-light);
    color: var(--orange-700);
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.td-link {
    text-align: center;
    white-space: nowrap;
}

.td-link-inner {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.link-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--accent);
    color: var(--white);
    border-radius: var(--radius-sm);
    font-size: 0.76rem;
    font-weight: 600;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.link-btn:hover {
    background: var(--accent-hover);
    text-decoration: none;
    color: var(--white);
    transform: translateY(-1px);
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state p {
    font-size: 0.9rem;
}

/* ============================================
   Pagination
   ============================================ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.page-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-bg);
}

.page-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(232, 112, 10, 0.3);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-info {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0 8px;
    font-weight: 500;
}

/* ============================================
   Footer
   ============================================ */

.footer {
    background: var(--gray-900);
    color: var(--gray-400);
    text-align: center;
    padding: 22px 24px;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
}

/* ============================================
   Animations
   ============================================ */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.fade-in-up {
    animation: fadeInUp 0.5s var(--transition-slow) forwards;
}

/* Counter animation helper */
.counting {
    animation: pulse 0.4s ease;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 1360px) {
    .cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 14px 16px;
    }

    .header-text h1 {
        font-size: 1.12rem;
    }

    .main {
        padding: 20px 16px 40px;
        gap: 20px;
    }

    .scrape-card {
        flex-direction: column;
        padding: 22px 20px;
        text-align: center;
    }

    .scrape-info p {
        max-width: 100%;
    }

    .scrape-controls {
        width: 100%;
        justify-content: center;
    }

    .progress-row {
        grid-template-columns: 130px 1fr 40px;
        gap: 10px;
    }

    .progress-section {
        padding: 16px 18px;
    }

    .cards-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px 14px;
    }

    .stat-value {
        font-size: 1.35rem;
    }

    .section-card {
        padding: 20px 16px;
    }

    .table-responsive {
        margin: 0 -16px;
        padding: 0 16px;
    }

    .search-wrapper {
        max-width: 100%;
    }

    .td-judul {
        min-width: 220px;
    }
}

@media (max-width: 480px) {
    .stat-card {
        flex-direction: row;
        align-items: center;
    }

    .header-text h1 {
        font-size: 1rem;
    }

    .btn-scrape {
        width: 100%;
        justify-content: center;
    }

    .pagination {
        gap: 4px;
    }

    .page-btn {
        min-width: 34px;
        height: 34px;
        font-size: 0.8rem;
    }
}

/* ============================================
   Header User Info
   ============================================ */

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-user {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border: 1.5px solid var(--accent);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-logout:hover {
    background: var(--accent);
    color: var(--white);
    text-decoration: none;
    box-shadow: var(--shadow-accent);
}

/* ============================================
   External link icon in table
   ============================================ */

.link-ext {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-left: 4px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition-fast);
    vertical-align: middle;
    text-decoration: none;
}

.link-ext:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-bg);
    text-decoration: none;
}

/* ============================================
   Login Page
   ============================================ */

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gray-100) 0%, var(--orange-50) 100%);
    padding: 24px;
}

.login-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    padding: 40px 36px;
    width: 100%;
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
    margin-bottom: 4px;
}

.login-brand-text h1 {
    font-size: 1.1rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.login-brand-text p {
    font-size: 0.78rem;
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-top: 3px;
}

.login-divider {
    height: 1px;
    background: var(--border-color);
    margin: 24px 0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.form-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.92rem;
    color: var(--text-primary);
    background: var(--gray-50);
    outline: none;
    transition: all var(--transition-fast);
}

.form-input:focus {
    border-color: var(--accent);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(232, 112, 10, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.input-password-wrapper {
    position: relative;
}

.input-password-wrapper .form-input {
    padding-right: 44px;
}

.btn-toggle-pw {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color var(--transition-fast);
}

.btn-toggle-pw:hover {
    color: var(--text-secondary);
}

.form-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.84rem;
    font-weight: 500;
    margin-bottom: 14px;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--orange-500) 0%, var(--orange-600) 100%);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-accent);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
}

.btn-login:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(232, 112, 10, 0.35);
}

.btn-login:disabled {
    opacity: 0.75;
    cursor: not-allowed;
}

.btn-login .btn-loader {
    display: none;
    position: absolute;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.login-footer {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ============================================
   Berita Detail Page
   ============================================ */

.breadcrumb {
    margin-bottom: 8px;
}

.breadcrumb-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.breadcrumb-link:hover {
    color: var(--accent);
    text-decoration: none;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 80px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.error-state {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 80px 20px;
    color: var(--text-muted);
    text-align: center;
}

.error-state p {
    font-size: 0.92rem;
    color: var(--text-secondary);
}

.btn-back-home {
    display: inline-flex;
    align-items: center;
    padding: 10px 22px;
    background: var(--accent);
    color: var(--white);
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.88rem;
    text-decoration: none;
    transition: all var(--transition-base);
}

.btn-back-home:hover {
    background: var(--accent-hover);
    text-decoration: none;
    color: var(--white);
    transform: translateY(-1px);
}

.article-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 40px 48px;
    box-shadow: var(--shadow-sm);
}

.article-header {
    margin-bottom: 0;
}

.article-title {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.35;
    letter-spacing: -0.02em;
    margin-bottom: 20px;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.84rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.meta-item svg {
    flex-shrink: 0;
    color: var(--accent);
}

.meta-link {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.meta-link:hover {
    text-decoration: underline;
    color: var(--accent-hover);
}

.meta-divider {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--gray-400);
    flex-shrink: 0;
}

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

/* ── Klasifikasi KBLI & Aktivitas Ekonomi ── */
.article-classification {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 18px;
    padding: 16px 20px;
    background: var(--orange-50);
    border: 1px solid var(--orange-200);
    border-radius: var(--radius-md);
}

.classification-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.classification-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--orange-700);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    min-width: 130px;
    flex-shrink: 0;
}

.classification-label svg {
    color: var(--accent);
    flex-shrink: 0;
}

.classification-badge {
    font-size: 0.84rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.classification-badge strong {
    color: var(--orange-600);
    font-weight: 700;
}

.classification-badge.badge-irrelevant {
    color: var(--text-muted);
    font-style: italic;
}

.classification-badge.badge-pending {
    color: var(--text-muted);
    font-style: italic;
}

@media (max-width: 600px) {
    .classification-item {
        flex-direction: column;
        gap: 4px;
    }
    .classification-label {
        min-width: unset;
    }
}

.article-divider {
    height: 1px;
    background: var(--border-color);
    margin: 24px 0;
}

.article-body {
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.85;
}

.article-body p {
    margin-bottom: 1.15em;
}

.article-body p:last-child {
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .article-card {
        padding: 24px 20px;
    }

    .article-title {
        font-size: 1.3rem;
    }

    .login-card {
        padding: 28px 20px;
    }

    .header-user-info {
        display: none;
    }
}

/* ============================================
   Scrollbar Styling
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* ============================================
   AI Insight Section
   ============================================ */

.ai-insight-section {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.ai-insight-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.ai-insight-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--text-primary);
}

.ai-insight-title svg {
    color: var(--accent);
    flex-shrink: 0;
}

.ai-insight-subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
    padding-left: 30px;
}

.ai-insight-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.ai-article-count {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    font-size: 0.76rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.btn-refresh-ai {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    background: var(--white);
    color: var(--accent);
    border: 1.5px solid var(--accent);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.btn-refresh-ai:hover {
    background: var(--accent);
    color: var(--white);
    box-shadow: var(--shadow-accent);
    transform: translateY(-1px);
}

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

.btn-refresh-ai.loading {
    pointer-events: none;
    opacity: 0.6;
}

.btn-refresh-ai.loading svg {
    animation: spin 0.8s linear infinite;
}

/* Grid layout */

.ai-insight-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

/* Individual card */

.ai-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 18px 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: box-shadow var(--transition-base);
}

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

.ai-card-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.ai-card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--gray-100);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-card-pdrb .ai-card-icon {
    background: #DBEAFE;
    color: #2563EB;
}

.ai-card-kemiskinan .ai-card-icon {
    background: #FEE2E2;
    color: #DC2626;
}

.ai-card-pengangguran .ai-card-icon {
    background: #DCFCE7;
    color: #16A34A;
}

.ai-card-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 2px;
    color: var(--text-muted);
}

.ai-card-title {
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.ai-card-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Body */

.ai-card-body {
    flex: 1;
}

.ai-insight-text {
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.75;
    margin: 0;
}

/* Skeleton shimmer */

.ai-skeleton {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 0;
}

.ai-skeleton-line {
    height: 14px;
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    border-radius: 6px;
    animation: shimmer 1.4s ease-in-out infinite;
    width: 100%;
}

.ai-skeleton-line.w80 { width: 80%; }
.ai-skeleton-line.w90 { width: 90%; }
.ai-skeleton-line.w70 { width: 70%; }

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Error state */

.ai-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.82rem;
    color: #DC2626;
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    line-height: 1.5;
}

.ai-error svg {
    flex-shrink: 0;
    margin-top: 1px;
}

/* Responsive */

@media (max-width: 900px) {
    .ai-insight-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .ai-insight-subtitle {
        padding-left: 0;
    }
}

/* Custom Period Dropdown */

.ai-period-dropdown {
    position: relative;
}

.ai-period-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px 8px 12px;
    background: var(--white);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    white-space: nowrap;
    user-select: none;
}

.ai-period-btn > svg:first-child {
    color: var(--accent);
    flex-shrink: 0;
}

.ai-period-btn:hover,
.ai-period-btn.open {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232, 112, 10, 0.1);
}

.ai-period-chevron {
    color: var(--text-muted);
    margin-left: 2px;
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.ai-period-btn.open .ai-period-chevron {
    transform: rotate(180deg);
}

.ai-period-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 210px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 28px rgba(0,0,0,0.12);
    padding: 6px;
    z-index: 200;
    animation: ai-menu-in 140ms ease;
}

@keyframes ai-menu-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.ai-period-group-label {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 8px 10px 4px;
}

.ai-period-group-label:first-child {
    padding-top: 2px;
}

.ai-period-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.ai-period-option span {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
}

.ai-period-option:hover {
    background: var(--orange-50);
    color: var(--accent);
}

.ai-period-option:hover span {
    color: var(--orange-500);
}

.ai-period-option.active {
    background: var(--orange-100);
    color: var(--accent);
    font-weight: 700;
}

.ai-period-option.active span {
    color: var(--orange-600);
}

.ai-period-option.active::after {
    content: "✓";
    font-size: 0.78rem;
    color: var(--accent);
    margin-left: auto;
    padding-left: 8px;
}

/* Loading status bar */

.ai-loading-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--orange-50) 0%, var(--white) 100%);
    border: 1px solid var(--orange-200);
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    color: var(--orange-700);
    font-weight: 500;
}

.ai-loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: ai-dot-pulse 1.2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes ai-dot-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.7); }
}

/* Card pulse animation during loading */

.ai-card-loading {
    animation: ai-card-pulse 2s ease-in-out infinite;
}

@keyframes ai-card-pulse {
    0%, 100% { box-shadow: none; }
    50%       { box-shadow: 0 0 0 3px rgba(232, 112, 10, 0.15); }
}

/* Sources collapsible */

.ai-sources-wrap {
    border-top: 1px solid var(--gray-100);
    padding-top: 10px;
    margin-top: 2px;
}

.ai-sources-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    padding: 0;
    font-family: var(--font-family);
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.ai-sources-toggle:hover {
    color: var(--accent);
}

.ai-sources-toggle svg {
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.ai-sources-toggle.open svg {
    transform: rotate(180deg);
}

.ai-sources-list {
    list-style: none;
    padding: 8px 0 0 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-sources-list li a {
    font-size: 0.76rem;
    color: var(--text-secondary);
    text-decoration: none;
    line-height: 1.4;
    display: block;
    padding: 2px 0;
    transition: color var(--transition-fast);
    border-bottom: 1px dotted transparent;
}

.ai-sources-list li a:hover {
    color: var(--accent);
    text-decoration: none;
    border-bottom-color: var(--accent);
}

.ai-sources-list li a::before {
    content: "↗ ";
    font-size: 0.68rem;
    opacity: 0.5;
}

/* Year select dropdown */

.ai-year-select {
    appearance: none;
    -webkit-appearance: none;
    padding: 8px 28px 8px 12px;
    background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 8px center;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    white-space: nowrap;
    min-width: 76px;
}

.ai-year-select:hover,
.ai-year-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232, 112, 10, 0.1);
    outline: none;
}

/* Inline citation — academic superscript footnote style */

.ai-cite {
    display: inline;
    font-size: 0.7em;
    font-weight: 700;
    font-family: var(--font-family);
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 1px;
    text-decoration-style: dotted;
    vertical-align: super;
    line-height: 0;
    margin: 0 1px;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--transition-fast);
}

.ai-cite:hover {
    color: var(--accent-hover, #c25e00);
    text-decoration: underline;
    text-decoration-style: solid;
}

/* ============================================
   Floating AI Chat
   ============================================ */

.chat-fab {
    position: fixed;
    right: 20px;
    bottom: 22px;
    z-index: 280;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--orange-500) 0%, var(--orange-600) 100%);
    color: var(--white);
    font-family: var(--font-family);
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-accent);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.chat-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(232, 112, 10, 0.35);
}

.chat-window {
    position: fixed;
    right: 20px;
    bottom: 84px;
    width: min(480px, calc(100vw - 28px));
    height: min(640px, calc(100vh - 120px));
    z-index: 300;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    box-shadow: 0 14px 42px rgba(0, 0, 0, 0.18);
    display: none;
    grid-template-rows: auto 1fr auto auto;
    overflow: hidden;
}

.chat-window.open {
    display: grid;
    animation: ai-menu-in 140ms ease;
}

.chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(140deg, var(--orange-50) 0%, var(--white) 85%);
    border-bottom: 1px solid var(--gray-200);
}

.chat-header h3 {
    font-size: 0.94rem;
    color: var(--text-primary);
}

.chat-header p {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.chat-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chat-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    background: var(--white);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chat-icon-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-bg);
}

.chat-body {
    overflow-y: auto;
    padding: 14px;
    background: linear-gradient(180deg, #fff 0%, #fffcf9 100%);
}

.chat-empty {
    font-size: 0.82rem;
    color: var(--text-muted);
    border: 1px dashed var(--gray-300);
    border-radius: 10px;
    padding: 12px;
    line-height: 1.5;
}

.chat-msg {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
}

/* Assistant messages wrap agar follow-up bisa turun ke baris baru */
.chat-msg.assistant {
    flex-wrap: wrap;
}

.chat-msg.user {
    justify-content: flex-end;
}

/* Avatar logo chatbot — hanya muncul di pesan assistant */
.chat-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 2px;
    /* Sedikit shadow agar terlihat di background terang */
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
}

.chat-bubble {
    max-width: 88%;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.83rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.chat-msg.user .chat-bubble {
    background: linear-gradient(145deg, var(--orange-500) 0%, var(--orange-600) 100%);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.chat-msg.assistant .chat-bubble {
    background: var(--gray-50);
    color: var(--text-primary);
    border: 1px solid var(--gray-200);
    border-bottom-left-radius: 4px;
}

/* ── Follow-up question chips ──────────────────────────────────────────────── */

.chat-followups {
    /* Ambil lebar penuh agar turun ke baris baru di bawah avatar+bubble */
    width: 100%;
    flex: 0 0 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    /* Indent sejajar dengan bubble: lebar avatar (28px) + gap (8px) */
    padding-left: 36px;
    margin-top: 4px;
    margin-bottom: 4px;
}

.chat-followup-btn {
    background: none;
    border: 1.5px solid var(--accent);
    color: var(--accent);
    border-radius: 20px;
    padding: 5px 13px;
    font-size: 0.76rem;
    font-weight: 500;
    cursor: pointer;
    line-height: 1.4;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
    font-family: var(--font-family);
    max-width: 100%;
}

.chat-followup-btn:hover {
    background: var(--accent);
    color: var(--white);
    transform: translateY(-1px);
}

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

.md-content {
    font-size: 0.83rem;
    line-height: 1.62;
}

.md-content p {
    margin: 0 0 0.6em;
}

.md-content p:last-child {
    margin-bottom: 0;
}

.md-content ul,
.md-content ol {
    margin: 0.35em 0 0.7em 1.15em;
    padding: 0;
}

.md-content li {
    margin: 0.25em 0;
}

.md-content strong {
    font-weight: 800;
}

.md-content em {
    font-style: italic;
}

.md-content code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78em;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 4px;
    padding: 1px 4px;
}

.md-content blockquote {
    margin: 0.5em 0;
    padding: 0.35em 0.7em;
    border-left: 3px solid var(--orange-300);
    background: var(--orange-50);
    border-radius: 6px;
}

.chat-citations {
    margin-top: 8px;
    font-size: 0.73rem;
    color: var(--text-secondary);
}

.chat-citations a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dotted var(--accent);
    margin-right: 6px;
}

.chat-citations a:hover {
    text-decoration: none;
    border-bottom-style: solid;
}

.chat-inline-cite {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 2px;
    margin-right: 1px;
    vertical-align: super;
    line-height: 1;
    font-size: 0.72em;
    font-weight: 700;
    text-decoration: none;
}

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

.chat-typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 0 14px 8px;
    color: var(--text-muted);
    font-size: 0.74rem;
}

.chat-typing span {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    display: inline-block;
    animation: ai-dot-pulse 1.1s ease-in-out infinite;
}

.chat-typing span:nth-child(2) {
    animation-delay: .12s;
}

.chat-typing span:nth-child(3) {
    animation-delay: .24s;
}

.chat-input-wrap {
    border-top: 1px solid var(--gray-200);
    background: var(--white);
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.chat-input {
    width: 100%;
    resize: none;
    border: 1px solid var(--gray-300);
    border-radius: 10px;
    padding: 9px 10px;
    font-family: var(--font-family);
    font-size: 0.82rem;
    outline: none;
    min-height: 42px;
    max-height: 110px;
}

.chat-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232, 112, 10, 0.12);
}

.chat-send {
    border: none;
    border-radius: 10px;
    padding: 0 14px;
    min-height: 42px;
    background: var(--accent);
    color: var(--white);
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.chat-send:hover {
    background: var(--accent-hover);
}

.chat-send:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.chat-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 380;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    background: rgba(15, 23, 42, 0.38);
    backdrop-filter: blur(2px);
}

.chat-modal-backdrop[hidden] {
    display: none !important;
}

.chat-modal {
    width: min(420px, 100%);
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
    padding: 16px;
    animation: ai-menu-in 120ms ease;
}

.chat-modal-title {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 7px;
}

.chat-modal-message {
    font-size: 0.84rem;
    color: var(--text-secondary);
    line-height: 1.55;
}

.chat-modal-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.chat-modal-btn {
    border: none;
    border-radius: 9px;
    padding: 8px 12px;
    font-family: var(--font-family);
    font-size: 0.79rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chat-modal-btn.secondary {
    color: var(--text-secondary);
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
}

.chat-modal-btn.secondary:hover {
    background: var(--gray-200);
}

.chat-modal-btn.primary {
    color: var(--white);
    background: var(--accent);
}

.chat-modal-btn.primary:hover {
    background: var(--accent-hover);
}

.chat-modal-btn.primary.danger {
    background: #dc2626;
}

.chat-modal-btn.primary.danger:hover {
    background: #b91c1c;
}

@media (max-width: 768px) {
    .chat-fab {
        right: 14px;
        bottom: 16px;
    }

    .chat-window {
        right: 10px;
        left: 10px;
        width: auto;
        bottom: 74px;
        height: min(78vh, 560px);
    }

    .chat-modal {
        border-radius: 12px;
        padding: 14px;
    }
}

/* ============================================
   App Shell Sidebar Layout (Rebuild)
   ============================================ */

:root {
    --sidebar-width: 270px;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
    background: radial-gradient(circle at top right, #fff5e8 0%, var(--bg-body) 45%);
}

.app-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 18px 14px 16px;
    border-right: 1px solid var(--gray-200);
    background: linear-gradient(180deg, #fffaf4 0%, #ffffff 74%);
    display: flex;
    flex-direction: column;
    gap: 18px;
    z-index: 130;
}

.sidebar-brand {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 8px 12px;
    border-bottom: 1px solid var(--gray-200);
}

.sidebar-brand h1 {
    font-size: 0.92rem;
    line-height: 1.28;
    letter-spacing: -0.01em;
}

.sidebar-brand p {
    margin-top: 2px;
    font-size: 0.74rem;
    color: var(--text-muted);
}

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

.sidebar-link {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 10px;
    padding: 10px 12px;
    text-align: left;
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-family);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.sidebar-link-icon {
    flex-shrink: 0;
}

.sidebar-link-label {
    min-width: 0;
}

.sidebar-link:hover {
    background: var(--orange-50);
    border-color: var(--orange-200);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: linear-gradient(90deg, #fff1e0 0%, #fff8ef 100%);
    border-color: var(--orange-300);
    color: var(--orange-700);
    box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-link-anchor {
    display: block;
    text-decoration: none;
}

.sidebar-link-anchor:hover {
    text-decoration: none;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--gray-200);
    padding: 12px 8px 0;
    display: grid;
    gap: 8px;
}

.sidebar-footer .header-user {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.sidebar-footer .btn-logout {
    justify-content: center;
}

.sidebar-overlay {
    display: none;
}

.app-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-shell.sidebar-collapsed {
    grid-template-columns: 84px 1fr;
}

.app-shell.sidebar-collapsed .sidebar-brand {
    justify-content: center;
}

.app-shell.sidebar-collapsed .sidebar-brand div {
    display: none;
}

.app-shell.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding-inline: 8px;
}

.app-shell.sidebar-collapsed .sidebar-link-label {
    display: none;
}

.app-shell.sidebar-collapsed .sidebar-footer .header-user {
    display: none;
}

.app-shell.sidebar-collapsed .sidebar-footer .btn-logout {
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 0;
    position: relative;
    border-radius: 10px;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
}

.app-shell.sidebar-collapsed .sidebar-footer .btn-logout::before {
    content: "";
    width: 16px;
    height: 16px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' y1='12' x2='9' y2='12'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' y1='12' x2='9' y2='12'/%3E%3C/svg%3E") center / contain no-repeat;
}

.app-content .header {
    position: sticky;
    top: 0;
    z-index: 120;
    border-bottom: 1px solid var(--orange-200);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
}

.app-content .header-inner {
    max-width: 100%;
    padding: 14px 22px;
}

.header-brand-main {
    gap: 10px;
}

.header-brand-main h1 {
    font-size: 1.05rem;
    letter-spacing: -0.015em;
}

.header-brand-main .header-subtitle {
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.sidebar-toggle {
    width: 36px;
    height: 36px;
    border: 1px solid var(--gray-300);
    border-radius: 10px;
    background: #fff;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.app-content .main {
    max-width: 100%;
    margin: 0;
    padding: 20px 22px 30px;
    gap: 20px;
}

.app-view.view-hidden {
    display: none !important;
}

.main.is-chat-mode {
    display: none;
}

.app-content .footer {
    margin-top: auto;
    border-top: 1px solid var(--gray-200);
    background: rgba(255, 255, 255, 0.9);
}

/* Chat sebagai menu utama */
.chat-window {
    position: static;
    right: auto;
    bottom: auto;
    width: auto;
    height: calc(100vh - 160px);
    min-height: 560px;
    margin: 20px 22px 26px;
    border-radius: 14px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
    display: grid;
    grid-template-rows: auto 1fr auto auto;
}

.chat-window.open {
    display: grid;
}

.chat-header {
    padding: 14px 16px;
}

.chat-header h3 {
    font-size: 1rem;
}

.chat-header p {
    font-size: 0.76rem;
}

.chat-body {
    padding: 16px;
}

.chat-msg {
    margin-bottom: 12px;
}

.chat-bubble {
    max-width: min(980px, 88%);
    font-size: 0.86rem;
}

.chat-input-wrap {
    padding: 12px;
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-shell.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: min(300px, 88vw);
        transform: translateX(-102%);
        transition: transform 220ms ease;
        box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
    }

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

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.4);
        opacity: 0;
        visibility: hidden;
        transition: opacity 180ms ease;
        z-index: 125;
    }

    .app-shell.sidebar-open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }
}

@media (max-width: 768px) {
    .app-content .header-inner {
        padding: 12px 14px;
    }

    .app-content .main {
        padding: 14px 12px 22px;
    }

    .chat-window {
        margin: 14px 12px 20px;
        min-height: 72vh;
        height: calc(100vh - 140px);
        border-radius: 12px;
    }

    .chat-bubble {
        max-width: 96%;
    }

    .chat-input-wrap {
        grid-template-columns: 1fr;
    }

    .chat-send {
        min-height: 38px;
    }
}

.app-content.chat-view-active {
    height: 100vh;
    overflow: hidden;
}

.app-content.chat-view-active .chat-window {
    height: calc(100vh - 96px);
    min-height: 0;
    margin-top: 0;
    margin-bottom: 0;
}

.app-content.chat-view-active .footer {
    display: none;
}

body.chat-view-lock {
    overflow: hidden;
}

.app-content.chat-view-active .chat-window {
    position: fixed;
    top: 72px;
    left: calc(var(--sidebar-width) + 22px);
    right: 22px;
    width: auto;
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    z-index: 115;
}

.app-content.chat-view-active .chat-header,
.app-content.chat-view-active .chat-input-wrap,
.app-content.chat-view-active .chat-help,
.app-content.chat-view-active .chat-empty {
    border: none;
    background: var(--white);
}

.app-content.chat-view-active .chat-header {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.app-content.chat-view-active .chat-help,
.app-content.chat-view-active .chat-input-wrap {
    border: none;
}

.app-content.chat-view-active .chat-input-wrap {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.app-content.chat-view-active .chat-body {
    background: linear-gradient(180deg, #fff 0%, #fffcf9 100%);
    border: none;
}

.app-shell.sidebar-collapsed .app-content.chat-view-active .chat-window {
    left: 106px;
}

@media (max-width: 1100px) {
    .app-content.chat-view-active .chat-window {
        left: 16px;
        right: 16px;
        top: 66px;
    }
}

@media (max-width: 768px) {
    .app-content.chat-view-active .chat-window {
        left: 10px;
        right: 10px;
        top: 62px;
        height: calc(100vh - 74px);
    }
}
