:root {
  --bg:#0f172a;--surface:#1e293b;--primary:#3b82f6;
  --text:#f8fafc;
  --text-muted:#94a3b8;
  --border:#334155;
  --shadow:0 4px 12px rgba(0,0,0,.4);
  --radius:16px;
  --brand-gold: #D4AF37;
  --brand-gold-light: #FFD700;
  --brand-gold-dark: #B8941F;
  --brand-silver: #C0C0C0;
  --brand-silver-light: #E8E8E8;
  --brand-silver-dark: #A8A8A8;
  --brand-gradient: linear-gradient(135deg, #D4AF37 0%, #C0C0C0 100%);
  --brand-gradient-reverse: linear-gradient(135deg, #C0C0C0 0%, #D4AF37 100%);
  --primary: var(--brand-gold);
  --primary-dark: var(--brand-gold-dark);
  --secondary: var(--brand-silver);
}

*{box-sizing:border-box;margin:0;padding:0}body{font-family:system-ui,-apple-system,sans-serif;background:var(--bg);color:var(--text);line-height:1.5;min-height:100vh}
.top-bar{display:flex;justify-content:space-between;align-items:center;padding:1rem;background:var(--surface);position:sticky;top:0;z-index:10;box-shadow:var(--shadow)}
.logo{font-weight:800;font-size:1.4rem;color:var(--primary)}.user-info{display:flex;align-items:center;gap:1rem;font-size:.9rem}
.btn-sm{padding:.4rem .8rem;background:rgba(255,255,255,.1);border-radius:6px;color:var(--text);text-decoration:none;font-size:.8rem}
.lang-switcher { margin-left: 1rem; }
.lang-switcher select { cursor: pointer; }
.lang-switcher select:focus { outline: none; border-color: #3b82f6; }
.btn-sm:hover{background:rgba(255,255,255,.2)}
.mobile-nav{display:grid;grid-template-columns:repeat(5,1fr);gap:8px;padding:1rem;background:var(--surface);border-bottom:1px solid var(--border)}
.nav-item{display:flex;flex-direction:column;align-items:center;padding:12px 4px;border-radius:12px;text-decoration:none;color:var(--text-muted);transition:.2s}
.nav-item:hover,.nav-item.active{background:rgba(59,130,246,.15);color:var(--primary)}
.nav-icon{font-size:1.5rem;margin-bottom:4px}.nav-text{font-size:.75rem;font-weight:500}
.content-area{padding:1rem;max-width:1200px;margin:0 auto}.stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:1rem;margin-top:1rem}
.stat-card{background:var(--surface);padding:1.5rem;border-radius:var(--radius);box-shadow:var(--shadow);border:1px solid var(--border)}
.stat-num{font-size:2rem;font-weight:700;color:var(--primary)}.stat-label{color:var(--text-muted);font-size:.9rem;margin-top:.5rem}
/* === RESPONSIVE NAVIGATION - FIXED FOR 5-COLUMN MOBILE === */
.app-nav {
    display: grid;
    /* Desktop: auto-fit dengan min-width nyaman */
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 0.4rem;
    padding: 0.5rem;
    background: var(--surface, #1e293b);
    border-bottom: 1px solid var(--border, #334155);
    position: sticky;
    top: 0;
    z-index: 100;
    /* Prevent overflow */
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}
.app-nav::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Compact padding for mobile */
    padding: 0.5rem 0.25rem;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-muted, #94a3b8);
    font-size: 0.7rem;
    font-weight: 500;
    transition: all 0.2s ease;
    /* Fixed min-height for touch target */
    min-height: 56px;
    gap: 0.25rem;
    /* Prevent text overflow */
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    /* Critical: allow shrinking */
    flex-shrink: 1;
    min-width: 0;
    box-sizing: border-box;
}

.nav-item:hover {
    background: rgba(212, 175, 55, 0.1);
    color: var(--brand-gold, #D4AF37);
    transform: translateY(-1px);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--brand-gold, #D4AF37), var(--brand-gold-dark, #B8941F));
    color: #fff;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.nav-icon {
    font-size: 1.3rem;
    line-height: 1;
    /* Prevent icon from forcing width */
    flex-shrink: 0;
}

.nav-text {
    /* Truncate long text elegantly */
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    /* Slightly smaller for mobile */
    font-size: 0.65rem;
    line-height: 1.2;
}

/* === MOBILE: EXACT 5-COLUMN GRID (No overflow!) === */
@media (max-width: 768px) {
    .app-nav {
        /* Force exact 5 columns */
        grid-template-columns: repeat(5, 1fr);
        gap: 0.25rem;
        padding: 0.35rem;
    }
    
    .nav-item {
        padding: 0.4rem 0.15rem;
        min-height: 52px;
        font-size: 0.62rem;
        gap: 0.2rem;
    }
    
    .nav-icon {
        font-size: 1.15rem;
    }
    
    .nav-text {
        font-size: 0.6rem;
        /* Allow 2 lines max on very small screens */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        white-space: normal;
    }
}

/* === ULTRA SMALL SCREENS (<360px): Icon-only mode === */
@media (max-width: 360px) {
    .app-nav {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.2rem;
        padding: 0.3rem;
    }
    
    .nav-item {
        padding: 0.35rem 0.1rem;
        min-height: 48px;
        gap: 0.15rem;
    }
    
    .nav-icon {
        font-size: 1.1rem;
    }
    
    .nav-text {
        /* Hide text, show only icons on tiny screens */
        display: none;
    }
    
    .nav-item.active .nav-text {
        /* Show text only for active item */
        display: block;
        font-size: 0.55rem;
        position: absolute;
        bottom: -18px;
        left: 50%;
        transform: translateX(-50%);
        background: var(--brand-gold);
        color: #fff;
        padding: 2px 6px;
        border-radius: 4px;
        white-space: nowrap;
        z-index: 10;
        font-weight: 600;
    }
}

/* === DESKTOP: Comfortable spacing === */
@media (min-width: 1024px) {
    .app-nav {
        gap: 0.6rem;
        padding: 0.6rem 1rem;
    }
    .nav-item {
        padding: 0.7rem 0.5rem;
        min-height: 64px;
        font-size: 0.75rem;
        gap: 0.35rem;
    }
    .nav-icon {
        font-size: 1.5rem;
    }
    .nav-text {
        font-size: 0.7rem;
        -webkit-line-clamp: 1;
        white-space: nowrap;
    }
}

/* === Accessibility === */
.nav-item:focus {
    outline: none;
}
.nav-item:focus-visible {
    outline: 2px solid var(--brand-gold);
    outline-offset: 2px;
    border-radius: 10px;
}


/* === MODERN MODAL STYLES === */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.85); /* Dark overlay */
    backdrop-filter: blur(8px); /* Blur effect */
    z-index: 9999;
    display: none; /* Hidden by default */
    justify-content: center; align-items: center;
    opacity: 0; transition: opacity 0.3s ease;
}
.modal-overlay.active { opacity: 1; }

.modal-content {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 1px solid #334155;
    border-top: 4px solid #D4AF37; /* Gold Top Border */
    border-radius: 16px;
    width: 90%; max-width: 550px;
    padding: 0;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: #f8fafc;
    overflow: hidden;
}
.modal-overlay.active .modal-content { transform: translateY(0) scale(1); }

/* Header */
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.2rem 1.5rem;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid #334155;
}
.modal-header h3 { margin: 0; font-size: 1.25rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.close-btn { 
    background: #334155; border: none; color: #f8fafc; 
    width: 32px; height: 32px; border-radius: 50%; 
    font-size: 1.2rem; cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.close-btn:hover { background: #ef4444; transform: rotate(90deg); }

/* Body & Form */
.modal-body { padding: 1.5rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-full { grid-column: span 2; }

.modern-input {
    width: 100%; padding: 0.85rem 1rem;
    background: #0f172a; border: 1px solid #334155;
    border-radius: 10px; color: #f8fafc;
    font-size: 0.95rem; transition: all 0.2s;
    box-sizing: border-box; /* Fix padding width issue */
}
.modern-input:focus {
    outline: none; border-color: #D4AF37;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
    background: #1e293b;
}
.modern-input::placeholder { color: #64748b; }

.form-label { 
    display: block; margin-bottom: 0.4rem; 
    font-size: 0.85rem; color: #94a3b8; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}

/* Buttons */
.modal-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.btn-modal {
    flex: 1; padding: 0.9rem; border-radius: 10px; font-weight: 700; cursor: pointer;
    border: none; font-size: 0.95rem; transition: all 0.2s;
}
.btn-cancel { background: #334155; color: #e2e8f0; }
.btn-cancel:hover { background: #475569; }
.btn-save { 
    background: linear-gradient(135deg, #D4AF37, #B8941F); color: #fff;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.25);
}
.btn-save:hover { filter: brightness(1.1); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(212, 175, 55, 0.4); }

/* Mobile Fix */
@media (max-width: 500px) { 
    .form-grid { grid-template-columns: 1fr; } 
    .form-full { grid-column: span 1; }
    .modal-actions { flex-direction: column-reverse; }
}
